nil is the literal null value for Objective-C objects,
NULL is the literal null value for arbitrary C pointers.
Main difference between nil & NULL is that you can send messages to nil, so you can use it in some places where NULL can't work.
Showing posts with label Objective C. Show all posts
Showing posts with label Objective C. Show all posts
The Ternary Operator (?:)
One line if statement:
int x = 23;
int y = 45;
NSLog(@"Largest number is %i", x > y ? x : y );
// logs: Largest number is 45
Getting phone UUID through iPhone SDK
//Creating UUID string with Objective C and iOS sdk
+ (NSString*) stringWithUUID {
CFUUIDRef uuidObj = CFUUIDCreate(nil);
NSString *uuidString = (NSString*)CFUUIDCreateString(nil, uuidObj);
CFRelease(uuidObj);
return [uuidString autorelease];
}
//or
[[NSProcessInfo processInfo] globallyUniqueString];
Subscribe to:
Posts (Atom)