2

Possible Duplicate:
Apple LLVM 4.0 new features on Xcode 4.4 (Literals)

I've read a this article.

i found great skills. is a about @operator.

Literals syntax is supported for NSArray, NSDictionary, and NSNumber objects, using the same ‘@’ operator as for NSString literals.

but, i can't find any sample code.

could you please some more explain about NSNumber, NSArray, NSDictionary using the @operator?

thanks.

Community
  • 1
  • 1

3 Answers3

1

You can find out about the new syntax in LLVM's manual page about Objective-C Literals.

rid
  • 61,078
  • 31
  • 152
  • 193
1

Mike ash wrote a very good article on the topic:

It covers the basics, as well as some really cool implementation details. This should at least get you started, if you have any other questions please leave a comment below!

Richard J. Ross III
  • 55,009
  • 24
  • 135
  • 201
0

The best docs I've seen so far are in the llvm man page.

  // integral literals.
  NSNumber *fortyTwo = @42;             // equivalent to [NSNumber numberWithInt:42]
  NSNumber *fortyTwoUnsigned = @42U;    // equivalent to [NSNumber numberWithUnsignedInt:42U]
  NSNumber *fortyTwoLong = @42L;        // equivalent to [NSNumber numberWithLong:42L]
  NSNumber *fortyTwoLongLong = @42LL;   // equivalent to [NSNumber numberWithLongLong:42LL]

  // floating point literals.
  NSNumber *piFloat = @3.141592654F;    // equivalent to [NSNumber numberWithFloat:3.141592654F]
  NSNumber *piDouble = @3.1415926535;   // equivalent to [NSNumber numberWithDouble:3.1415926535]

  // BOOL literals.
  NSNumber *yesNumber = @YES;           // equivalent to [NSNumber numberWithBool:YES]
  NSNumber *noNumber = @NO;             // equivalent to [NSNumber numberWithBool:NO]

  // This creates an NSArray with 3 elements. The comma-separated sub-expressions of an array
  // literal can be any Objective-C object pointer typed expression.
  NSArray *array = @[ @"Hello", NSApp, [NSNumber numberWithInt:42] ];

  // Immutable dictionary expression:
  NSDictionary *dictionary = @{
    @"name" : NSUserName(),
    @"date" : [NSDate date],
    @"processInfo" : [NSProcessInfo processInfo]
  };
drewish
  • 9,042
  • 9
  • 38
  • 51