December 2012
Beginner
552 pages
12h 58m
English
Program 15.3, which follows, shows how to define an NSString object and assign an initial value to it. It also shows how to use the format characters %@ to display an NSString object.
Program 15.3.
#import <Foundation/Foundation.h>int main (int argc, char * argv[]){ @autoreleasepool { NSString *str = @"Programming is fun"; NSLog (@"%@", str); } return 0;}
Program 15.3. Output
Programming is fun
In the line
NSString *str = @"Programming is fun";
the constant string object Programming is fun is assigned to the NSString variable str. Its value is then displayed using NSLog.
The NSLog format characters %@ can be used to display not just NSString objects, but other objects as well. For example, given ...
Read now
Unlock full access