Objc literals

download Objc literals

If you can't read please download the document

description

ios literals - [email protected]

Transcript of Objc literals

  • 1. iOS objective-C Literals Etribe-STG

2. Objectiv-C Literals Literal syntax Literal notation . iOS Xcode 4.4 LLVM 4.0 . . NSString *str = @AAA; , . . NSArray, NSDictionary, NSNumber 3. NSArray arr = [NSArray arrayWithObject:a, b, c, nil]; arr = @[a, b, c]; 4. NSDictionary dic = [NSDictionary dictionaryWithObjects:@[obj1, obj2, obj3] forKeys:@[key1, key2, key3]]; dic = @{ key1 : obj1, key2 : obj2, key3 : obj3 }; 5. NSNumber number = [NSNumber numberWithChar:'X']; number = [NSNumber numberWithInt:12345]; number = [NSNumber numberWithUnsignedLong:12345ul]; number = [NSNumber numberWithLongLong:12345ll]; number = [NSNumber numberWithFloat:123.45f]; number = [NSNumber numberWithDouble:123.45]; number = [NSNumber numberWithBool:YES]; number = @'X'; //char number = @12345; //int number = @12345ul; //unsigned long number = @12345ll; //long long number = @123.45f; //float number = @123.45; //double number = @YES; //bool 6. . . . . 7. http://ijoshsmith.com/2012/07/29/objec tive-c-literals-for-ios-in-xcode-4-4/ http://www.bignerdranch.com/blog/obj ective-c-literals-part-1/ http://soooprmx.com/wp/archives/tag/ objective-c-literal http://blog.jidolstar.com/842 http://clang.llvm.org/docs/ObjectiveCLit erals.html