我从 API 接收 JSON 格式的数据,在将数据转换为自定义类后,我试图将某些属性写入核心数据数据库。
我的代码是:
NSLog(@"topPost: %@; post(in): %@", topPostsEntity.totalAgainst,post.totalAgainst);
topPostsEntity.totalAgainst = post.totalAgainst;
NSLog(@"topPost: %@; post(in): %@", topPostsEntity.totalAgainst,post.totalAgainst);
topPostEntity 是一个核心数据实体。topPostEntity.totalAgainst 定义如下:
@property (nonatomic, retain) NSNumber * totalAgainst;
吸气剂没有什么特别的:
- (NSNumber *)totalAgainst
{
if (!_totalAgainst) _totalAgainst = [[NSNumber alloc]init];
return _totalAgainst;
}
post.totalAgainst 也被定义为一个 NSNumber,如下所示:
@property (nonatomic,strong) NSNumber *totalAgainst;
令我震惊的是,日志是这样写的:
2013-11-02 00:42:42.476 kello[6260:70b] topPost: 0; post(in): 40000
2013-11-02 00:42:42.476 kello[6260:70b] topPost: -25536; post(in): 40000
如何将 40000 分配给 topPostEntity.totalAgainst 使其存储 -25536?