CocoaHeads

  • Archive
  • RSS
  • Ask me anything
  • Submit
banner

Objective-C literals for NSDictionary, NSArray, and NSNumber

Objective-C literals: one can now create literals for NSArray, NSDictionary, and NSNumber (just like one can create literals for NSString)

NSArray Literals

Previously:

 array = [NSArray arrayWithObjects:a, b, c, nil];

Now:

array = @[ a, b, c ];

NSDictionary Literals

Previously:

dict = [NSDictionary dictionaryWithObjects:@[o1, o2, o3]

  forKeys:@[k1, k2, k3]];

Now:

dict = @{ k1 : o1, k2 : o2, k3 : o3 };

NSNumber Literals

Previously:

NSNumber *number;

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];

Now:

NSNumber *number;

number = @'X';

number = @12345;

number = @12345ul;

number = @12345ll;

number = @123.45f;

number = @123.45;

number = @YES;

    • #apple
    • #objective-c
    • #ObjC
    • #xcode
    • #cocoa
    • #mountain lion
    • #10.8
    • #llvm
    • #clang
  • 3 months ago
  • 86
  • Permalink
  • Share
    Tweet

86 Notes/ Hide

  1. wonwon-pierce reblogged this from cocoaheads
  2. de-realestate reblogged this from cocoaheads
  3. smokyonion reblogged this from cocoaheads
  4. rizwansattar liked this
  5. largemunchkin liked this
  6. joshtimonen reblogged this from cocoaheads and added:
    Apparently this is COMING SOON.
  7. gr4y liked this
  8. ellduin liked this
  9. jasonsjams liked this
  10. yulianii liked this
  11. kennygunie liked this
  12. kennygunie reblogged this from cocoaheads
  13. amirsaam reblogged this from cocoaheads
  14. jimmyhansen liked this
  15. inamiy liked this
  16. ldrer liked this
  17. shinyzhu liked this
  18. sumitpaul liked this
  19. seapomeranian reblogged this from cocoaheads
  20. neoroman liked this
  21. 1thingtoday liked this
  22. hengsu liked this
  23. xeokeri liked this
  24. guixing reblogged this from cocoaheads
  25. asmallteapot reblogged this from cocoaheads
  26. asmallteapot liked this
  27. fannheyward reblogged this from cocoaheads
  28. gabeprime liked this
  29. iamitv reblogged this from cocoaheads
  30. slowfocus liked this
  31. slowfocus reblogged this from cocoaheads
  32. elv1s liked this
  33. weavsnake liked this
  34. stiplady reblogged this from cocoaheads
  35. tarnfeld reblogged this from cocoaheads
  36. mike liked this
  37. samsonjs liked this
  38. samsonjs reblogged this from cocoaheads
  39. mfisher liked this
  40. gavinheer reblogged this from cocoaheads
  41. dielaughing liked this
  42. kadodka liked this
  43. kadodka reblogged this from cocoaheads
  44. iltofa reblogged this from cocoaheads
  45. jemerick liked this
  46. jagreenwood liked this
  47. overcyn reblogged this from cocoaheads
  48. royclarkson reblogged this from cocoaheads and added:
    Exciting times we live in.
  49. royclarkson liked this
  50. jstn liked this
  51. Show more notesLoading...
← Previous • Next →
  • RSS
  • Random
  • Archive
  • Ask me anything
  • Submit
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr