OBJ-C: Printing with NSString

// Printing a single NSString

NSString* string = @"hello world!";
printf("%s", [string UTF8String]);
printf("%s", [string cString]);

// Printing from an array of NSString

NSString* strings[3] = {@"1st string", @"2nd string", @"3rd string"};
for(int i=0; i<3; i++) {
    printf("%s", [strings[i] cString]);
}

No comments: