API에서 JSON으로 데이터를 받고 있으며 데이터를 사용자 지정 클래스로 변환 한 후 특정 속성을 코어 데이터 DB에 쓰려고합니다.
내 코드는 다음과 같습니다.
NSLog(@"topPost: %@; post(in): %@", topPostsEntity.totalAgainst,post.totalAgainst);
topPostsEntity.totalAgainst = post.totalAgainst;
NSLog(@"topPost: %@; post(in): %@", topPostsEntity.totalAgainst,post.totalAgainst);
topPostEntity는 Core-Data 엔티티입니다. 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
topPostEntity.totalAgainst에 40000을 할당하면 어떻게 -25536을 저장할 수 있습니까?
문제를 해결했습니다.
핵심 데이터 엔터티를 Integer 16으로 설정했습니다. 이것을 Integer 64로 변경하여 문제가 해결되었습니다. 나는 누군가가 자신의 문제를 돕기 위해이 q를 어떻게 찾을 수 있을지 모르겠지만, 그렇다면-환호합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다