I have NSDictionary
and I assign value of 'price' key to NSNumber
property of my object but when I log number value, it is an strange negative number!
item.price = [food valueForKey:@"price"];
price property is NSNumber
[[food valueForKey:@"price"] class]
will print __NSCFNumber
which is right.
[[food valueForKey:@"price"] intValue]
returns 0x000000000000c350
which is 50000
thats right
but when I log item.price
or [item.price integerValue]
it is -15536
which is completely wrong!
Any idea?
food json sample:
{ "title":"Pizza", "price":50000 }
Guess what?
all of this logs and problems shows my NSNumber property can't store some integers. but what range of integers? integers which are between -32,768 / 32,768
but why? because I have define my managed object price
property of kind NSInteger 16
!
I should define it as NSInteger 32