Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New Objective-c Literals in 4.4

I can write @42, which creates an NSNumber with int value 42. Can I do this with a variable, like @someIntVar? Obviously I tried it and it doesn't work (which sucks because then I have to go through [NSNumber numberWithInt:someIntVar]). Is it possible with a slightly different syntax?

like image 240
0xSina Avatar asked Feb 20 '23 09:02

0xSina


1 Answers

I strongly suggest you read the official clang documentation on the matter: http://clang.llvm.org/docs/ObjectiveCLiterals.html

But, to box a variable, or any expression, you can use parentheses:

 id num = @(someIntVar);
like image 188
Richard J. Ross III Avatar answered Mar 06 '23 07:03

Richard J. Ross III