fuzzygoat
fuzzygoat

Reputation: 26223

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 as a c-type integer and convert to a NSNumber object?

(e.g.)

NSLog(@"Enter Age:");
scanf("%d", &userAge);

gary

Upvotes: 1

Views: 1160

Answers (1)

Malaxeur
Malaxeur

Reputation: 6043

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

Upvotes: 5

Related Questions