开发者

Read Console Input As NSNumber?

开发者 https://www.devze.com 2022-12-09 15:06 出处:网络
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?

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...]

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号