Read Console Input As NSNumber?
Is there a way using the command line console to read a user typed value as an NSNumber, or do I have to read the input a开发者_如何学编程s a c-type integer and convert to a NSNumber object?
(e.g.)
NSLog(@"Enter Age:");
scanf("%d", &userAge);
gary
NSNumber is actually a class, not a primitive. (Unlike, say, NSInteger which is just a typedef'ed integer or long, depending on which machine you're running.)
I think you're going to have to read it in and then do [NSNumber numberWith...]
精彩评论