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
  • 1 year ago
  • 110
  • Permalink
  • Share
    Tweet

110 Notes/ Hide

  1. oneweekgame reblogged this from cocoaheads
  2. fcedillo likes this
  3. ricardofalasca reblogged this from cocoaheads
  4. iosadam reblogged this from cocoaheads
  5. mrakowski likes this
  6. amirmemon reblogged this from cocoaheads
  7. musiccodewine reblogged this from cocoaheads and added:
    A little while ago, I said I was going to take a wait and see approach with these literals. Well, with a new project...
  8. jeffcarp likes this
  9. artbgz reblogged this from cocoaheads and added:
    I don’t know how I can live without this (|l|O_o)
  10. artbgz likes this
  11. alexvinidiktov reblogged this from cocoaheads
  12. shiftingboundaries likes this
  13. myhandmadejewelry likes this
  14. fiftymill likes this
  15. stelabouras likes this
  16. marashliev likes this
  17. avenjamin likes this
  18. ania-springer reblogged this from cocoaheads
  19. mackmac reblogged this from cocoaheads
  20. halsk reblogged this from cocoaheads
  21. jdrama418 reblogged this from cocoaheads
  22. setimouse likes this
  23. wonwon-pierce reblogged this from cocoaheads
  24. smokyonion reblogged this from cocoaheads
  25. algorizms likes this
  26. largemunchkin likes this
  27. joshtimonen reblogged this from cocoaheads and added:
    Apparently this is COMING SOON.
  28. gr4y likes this
  29. ellduin likes this
  30. jasonsjams likes this
  31. yulianii likes this
  32. kennygunie reblogged this from cocoaheads
  33. kennygunie likes this
  34. amirsaam reblogged this from cocoaheads
  35. jimmyhansen likes this
  36. inamiy likes this
  37. ldrer likes this
  38. shinyzhu likes this
  39. sumitpaul likes this
  40. seapomeranian reblogged this from cocoaheads
  41. neoroman likes this
  42. 1thingtoday likes this
  43. hengsu likes this
  44. xeokeri likes this
  45. guixing reblogged this from cocoaheads
  46. asmallteapot reblogged this from cocoaheads and added:
    So excited.
  47. asmallteapot likes this
  48. writtenmontage likes this
  49. iamitv reblogged this from cocoaheads
  50. slowfocus reblogged this from cocoaheads
  51. Show more notesLoading...
← Previous • Next →
  • RSS
  • Random
  • Archive
  • Ask me anything
  • Submit
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr