Welcome, Guest. Please login or register.
Did you miss your activation email?
May 31, 2016, 08:36:27 PM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Recent Posts
Pages: 1 2 [3] 4 5 ... 10

 21 
 on: January 07, 2016, 05:30:45 AM 
Started by Cynthia99 - Last post by Leroygwen
No matter what time I want something, I'll come here. Because I can respond very well.

 22 
 on: January 07, 2016, 05:15:28 AM 
Started by alexsom - Last post by Leroygwen
Everyone on this show I have seen. I think not guilty Be a part of this community. And I will be a friend of the community.

 23 
 on: January 04, 2016, 03:56:48 AM 
Started by jeegee - Last post by jeegee
Thank you André!

 24 
 on: January 03, 2016, 01:20:56 PM 
Started by jeegee - Last post by anhe
Hello jeegee,

at least till Exercise 16.8 (this is where i am current learning) you can use the answers writen here in the forum for 4th and 5th edition.

kind regards

André

 25 
 on: January 03, 2016, 10:05:55 AM 
Started by jeegee - Last post by jeegee
Best wishes for 2016!

Does anyone know if the answers to the exercises of Programming in Objective-C sixth edition are available?

Thanks a lot!

 26 
 on: December 31, 2015, 07:50:25 AM 
Started by anhe - Last post by anhe
Hello all,

finally this is my last solution. For this chapter and for 2015  Wink.

Code: (Objective-C)
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
       
        NSURL *myURL2 = [NSURL URLWithString:@"http://bit.ly/aycNwd"];
        NSDictionary *buffer = [NSDictionary dictionaryWithContentsOfURL:myURL2];
       
        NSLog(@"%@", buffer);
       
    }
    return 0;
}

Result on standard output:

Code: (Objective-C)
{
    Alabama = Montgomery;
    Alaska = Juneau;
    Arizona = Phoenix;
    Arkansas = "Little Rock";
    California = Sacramento;
    Colorado = Denver;
    Connecticut = Hartford;
    Delaware = Dover;
    Florida = Tallahassee;
    Georgia = Atlanta;
    Hawaii = Honolulu;
    Idaho = Boise;
    Illinois = Springfield;
    Indiana = Indianapolis;
    Iowa = "Des Moines";
    Kansas = Topeka;
    Kentucky = Frankfort;
    Louisiana = "Baton Rouge";
    Maine = Augusta;
    Maryland = Annapolis;
    Massachusetts = Boston;
    Michigan = Lansing;
    Minnesota = "St. Paul";
    Mississippi = Jackson;
    Missouri = "Jefferson City";
    Montana = Helena;
    Nebraska = Lincoln;
    Nevada = "Carson City";
    "New Hampshire" = Concord;
    "New Jersey" = Trenton;
    "New Mexico" = "Santa Fe";
    "New York" = Albany;
    "North Carolina" = Raleigh;
    "North Dakota" = Bismarck;
    Ohio = Columbus;
    Oklahoma = "Oklahoma City";
    Oregon = Salem;
    Pennsylvania = Harrisburg;
    "Rhode Island" = Providence;
    "South Carolina" = Columbia;
    "South Dakota" = Pierre;
    Tennessee = Nashville;
    Texas = Austin;
    Utah = "Salt Lake City";
    Vermont = Montpelier;
    Virginia = Richmond;
    Washington = Olympia;
    "West Virginia" = Charleston;
    Wisconsin = Madison;
    Wyoming = Cheyenne;
}

kind regards and best wishes for 2016

André

 27 
 on: December 31, 2015, 05:19:16 AM 
Started by anhe - Last post by anhe
Hello all,

and this is my solution for exercise 16.7. In fact it is a simple variation of 16.6 with a substitution of

Code: (Objective-C)
outFile = [NSFileHandle fileHandleForWritingAtPath:@"testout"];

with:

Code: (Objective-C)
outFile = [NSFileHandle fileHandleWithStandardOutput];
.

Code: (Objective-C)
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
       
        // Get instance of NSFilemanager and get current directory path
        NSFileManager *fm = [NSFileManager defaultManager];
        NSString *path = [fm currentDirectoryPath];
        NSLog(@"Current directory path is: %@", path);
       
        NSFileHandle *inFile, *outFile;
        NSData *buffer = nil;
       
        // Open the file test for reading
        inFile = [NSFileHandle fileHandleForReadingAtPath:@"testfile3"];
       
        if (inFile == nil) {
            NSLog(@"Open of testfile for reading failed");
            return 1;
        }
       
        // Create the output file first if necessary
        [fm createFileAtPath:@"testout" contents:nil attributes:nil];
       
        // Now open outfile for writing
        outFile = [NSFileHandle fileHandleWithStandardOutput];
       
        NSInteger kBufSize = 128, kBufRead = 0;
   
        buffer = [inFile readDataOfLength:kBufSize];

       
        while ([buffer length] !=0) {
            NSLog(@"%li / %li", kBufRead, kBufSize);
            [inFile seekToFileOffset:kBufRead];
            buffer = [inFile readDataOfLength:kBufSize];
            [outFile writeData:buffer];
            kBufRead += kBufSize;
        }
       
        // Close the inFile
        [inFile closeFile];
       
    }
    return 0;
}


kind regards and my best wishes for 2016  Cheesy

André

 28 
 on: December 31, 2015, 04:13:05 AM 
Started by anhe - Last post by anhe
Hello all,

this is my solution for exercise 16.6:

Code: (Objective-C)
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
       
        // Get instance of NSFilemanager and get current directory path
        NSFileManager *fm = [NSFileManager defaultManager];
        NSString *path = [fm currentDirectoryPath];
        NSLog(@"Current directory path is: %@", path);
       
        NSFileHandle *inFile, *outFile;
        NSData *buffer = nil;
       
        // Open the file test for reading
        inFile = [NSFileHandle fileHandleForReadingAtPath:@"testfile3"];
       
        if (inFile == nil) {
            NSLog(@"Open of testfile for reading failed");
            return 1;
        }
       
        // Create the output file first if necessary
        //[[NSFileManager defaultManager] createFileAtPath:@"testout" contents:nil attributes:nil];
        [fm createFileAtPath:@"testout" contents:nil attributes:nil];
       
        // Now open outfile for writing
        outFile = [NSFileHandle fileHandleForWritingAtPath:@"testout"];
       
        if (outFile == nil) {
            NSLog(@"Open of testout for writing failed");
            return 2;
        }
       
        NSInteger kBufSize = 100, kBufRead = 0;
       
        // Truncate the output file since it may contain data
        [outFile truncateFileAtOffset:0];
        buffer = [inFile readDataOfLength:kBufSize];
       
        while ([buffer length] !=0) {
            NSLog(@"%li / %li", kBufRead, kBufSize);
            [outFile truncateFileAtOffset:kBufRead];
            [inFile seekToFileOffset:kBufRead];
            buffer = [inFile readDataOfLength:kBufSize];
            [outFile writeData:buffer];
            kBufRead += kBufSize;
            NSLog(@"Incremental Part of buffer: %@", [[NSString alloc]initWithData:buffer encoding:NSUTF8StringEncoding]);
        }
       
        // Close both files
        [inFile closeFile];
        [outFile closeFile];
       
        // Verify the file's contents
        NSLog(@"Final output: %@", [NSString stringWithContentsOfFile:@"testout" encoding:NSUTF8StringEncoding error:NULL]);
       

    }
    return 0;
}


kind regards

André

 29 
 on: December 28, 2015, 02:04:37 AM 
Started by anhe - Last post by anhe
Hello all,

this is my solution for exercise 16.5:

Code: (Objective-C)
#import <Foundation/Foundation.h>

@interface NSString (TempFiles)
+(NSString *) temporaryFileName;

@end

@implementation NSString (TempFiles)

+(NSString *) temporaryFileName
{
    NSString *tmpFileName = [NSTemporaryDirectory() stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]];
   
    return tmpFileName;
}

@end

int main(int argc, const char * argv[]) {
    @autoreleasepool {

        NSLog(@"Temporary file name: %@",[NSString temporaryFileName]);
    }
    return 0;
}


kind regards

André

Pages: 1 2 [3] 4 5 ... 10


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.