Has*_*jmi -1 objective-c nsdictionary nsnumber
我已经为对象的属性NSDictionary分配了'price'键的NSNumber值,但是当我记录数字值时,它是一个奇怪的负数!
item.price = [food valueForKey:@"price"];
Run Code Online (Sandbox Code Playgroud)
价格属性为 NSNumber
[[food valueForKey:@"price"] class]
Run Code Online (Sandbox Code Playgroud)
将打印__NSCFNumber正确的。
[[food valueForKey:@"price"] intValue]
Run Code Online (Sandbox Code Playgroud)
返回0x000000000000c350那是50000正确的
但是当我登录item.price或者[item.price integerValue]是-15536这是完全错误的!
任何的想法?
食物json样本:
{“ title”:“ Pizza”,“ price”:50000}
你猜怎么了?
所有这些日志和问题表明我的NSNumber属性无法存储一些整数。但是整数范围是多少?之间的整数-32,768 / 32,768
但为什么?因为我已经定义了我的托管对象price属性NSInteger 16!
我应该定义为 NSInteger 32
| 归档时间: |
|
| 查看次数: |
723 次 |
| 最近记录: |