I've been looking at autoboxing in Objective-C (here, for instance). Is there a new syntax for unboxing?
For instance, I want to do this but shorter:
NSArray *oneNumber = @[@1];
int one = ((NSNumber *)oneNumber[0]).intValue;
the second line's syntax is horrific. Is there any new language feature to deal with this?
@...
syntax for scalars and collections is, like the dot syntax, compiler shorthand for a concrete method call. Autoboxing would imply that a bare scalar (int x = 5;
) would be magically boxed when passed to a method that requiresNSNumber*
. (KVC'svalueForKey:
is auto-boxing / un-boxing, for example). – Affenpinscher