【发布时间】:2015-03-15 13:16:56
【问题描述】:
我有以下关系,图书实体工作正常。但是当我尝试提供关系并将其添加到愿望清单时,该值不会持续存在,它只是暂时可用。
这是我如何添加关系的代码
WishListBooks *wishList = [NSEntityDescription insertNewObjectForEntityForName:@"WishListBooks" inManagedObjectContext:[self getCoreDataContext]];
[wishList addContainsObject:self.bookEntity];
NSError *saveError;
if (![[self getCoreDataContext] save:&saveError]) {
NSLog(@"Saving changes to book book two failed: %@", saveError);
} else
{
NSLog(@"Data Saved onto Coredata");
}
但是当我打印我得到的日志时。
<_PFArray 0x79f31bf0>(
<WishListBooks: 0x79fc1730> (entity: WishListBooks; id: 0x79f9a3e0 <x-coredata://150C6D01-71AB-4324-B5F4-9D553630C985/WishListBooks/p1> ; data: <fault>),
<WishListBooks: 0x79fbe6f0> (entity: WishListBooks; id: 0x79f2a390 <x-coredata://150C6D01-71AB-4324-B5F4-9D553630C985/WishListBooks/p2> ; data: <fault>),
<WishListBooks: 0x79fb33d0> (entity: WishListBooks; id: 0x79fb4250 <x-coredata://150C6D01-71AB-4324-B5F4-9D553630C985/WishListBooks/p3> ; data: <fault>),
<WishListBooks: 0x79f34cd0> (entity: WishListBooks; id: 0x79fc5520 <x-coredata://150C6D01-71AB-4324-B5F4-9D553630C985/WishListBooks/p4> ; data: <fault>),
<WishListBooks: 0x79fb73e0> (entity: WishListBooks; id: 0x79fc5530 <x-coredata://150C6D01-71AB-4324-B5F4-9D553630C985/WishListBooks/p5> ; data: <fault>),
<WishListBooks: 0x79f35ae0> (entity: WishListBooks; id: 0x79fb1e50 <x-coredata://150C6D01-71AB-4324-B5F4-9D553630C985/WishListBooks/p6> ; data: <fault>)
)
【问题讨论】:
-
我还检查了 bookEntity 不是 null 或空