views:

377

answers:

3

Hi guys,

I can't figure out why it's not working, I have a NSString which I need to convert to NSNumber (to save it to Core Data) e.g

NSLog(stringNum); 

returns 1

NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
[f setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber *myNumber = [f numberFromString:stringNum];
[f release];

NSLog(@"myNumber = %i", myNumber); 

returns 120882496 or something like this

What am I missing? Thanks for help

+7  A: 

It's now an object, not an integer, therefore you must use %@ in NSLog, not %i.

Pascal
+2  A: 

myNumber is an object, so the format should be

@"myNumber = %@"

vikingosegundo
A: 

You are right guys, thanks for your help))))

Burjua