December 2013
Beginner
576 pages
16h 4m
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 ...
Read now
Unlock full access