November 2013
Beginner
325 pages
9h 47m
English
Instead of using #define, Objective-C programmers commonly use global variables to hold constant values.
Let’s add to your program to explain. First, there is a class named NSLocale that stores information about different geographical locations. You can get an instance of the user’s current locale and then ask it questions. For instance, if you wanted to know what the currency is in the user’s locale, you could ask for it like this:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
@autoreleasepool {
NSLog(@"\u03c0 is %f", M_PI);
NSLog(@"%d is larger", MAX(10, 12));
NSLocale *here = [NSLocale currentLocale]; NSString *currency = [here objectForKey:@"currency"]; NSLog(@"Money is %@", currency); ...Read now
Unlock full access