0
코어 데이터 엔티티로 해결할 수없는 문제가 있습니다.Coredata 플로트 번호가 0이됩니다
내 엔티티에는 두 개의 관계 (whoHasToPay, whoHasToBePaid)와 속성 (howMuch)이 있습니다.
이
내가 데이터베이스에 레코드를 삽입하는 코드입니다Debitcredit *dc = [NSEntityDescription
insertNewObjectForEntityForName:@"Debitcredit"
inManagedObjectContext:self.context];
dc.howMuch = [NSNumber numberWithFloat:5.2f];
dc.whoHasToPay = theDebitor;
dc.whoHasToBePaid = theCreditor;
NSLog(@"%@", dc);
[self.context save:&error];
NSLog는
<Debitcredit: 0x151590> (entity: Debitcredit; id: 0x141570
<x-coredata:///Debitcredit/t8DC4691F-5DE3-42D5-8095-C2D5D3264C8D2> ; data: {
howMuch = "5.2";
whoHasToBePaid = "0x140c50 <x-coredata://C25DC4FE-B46B-402C-B513-A2A83C6A9F86/Users/p1>";
whoHasToPay = "0x14c280 <x-coredata://C25DC4FE-B46B-402C-B513-A2A83C6A9F86/Users/p2>";
})
그렇게 값
howMuch
이 올 것 같다 보여줍니다. 그러나
, 내가
fetchRequestCount = [[NSFetchRequest alloc] init];
entityCount = [NSEntityDescription entityForName:@"Debitcredit"
inManagedObjectContext:self.context];
[fetchRequestCount setEntity:entityCount];
fetchedObjectsCount = [self.context executeFetchRequest:fetchRequestCount error:&error];
for (Debitcredit *dc in fetchedObjectsCount) {
NSLog(@"%f", [dc valueForKey:@"howMuch"]);
NSLog(@"%@", [[dc valueForKey:@"whoHasToPay"] name]);
NSLog(@"%@", [[dc valueForKey:@"whoHasToBePaid"] name]);
}
[fetchRequestCount release];
로 다시 호출 할 때 NSLog는
2010-12-05 01:47:04.636 myApp[6179:307] 0.000000
2010-12-05 01:47:04.642 myApp[6179:307] John
2010-12-05 01:47:04.646 myApp[6179:307] Jack
을 보여줍니다 howMuch
이 제로가 될 것 같다. 왜? 내가 잘못?
감사합니다. 이제 작동합니다! –