[Doing it Wrong] Auto Boxing of primitives
- by Jonathan
I can't seem to figure out how to get Objective-c to auto box my primitives.
I assumed that i would be able to do the following
NSString* foo = @"12.5";
NSNumber* bar;
bar = [foo floatValue];
However i find that i have used to the more verbose method of
NSString* foo = @"12.5";
NSNumber* bar;
bar = [NSNumber numberWithFloat:[foo floatValue]];
Am i doing it wrong or is this as good as it gets?