CoreData 关系内容不持久

CoreData Relationship Contents not persisting

我有以下关系,书实体工作正常。但是当我尝试提供关系并将其添加到愿望清单时,该值不会持续存在,它只是暂时可用。

这是我添加关系的代码

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>)
)

您看到的是核心数据故障。这些不是错误,也不表示未保存关系数据。当 Core Data 从持久存储中加载数据时,它会将其加载为 fault,这意味着它是一个尚未加载其属性值的占位符对象。如果您尝试使用这些属性值,它们会按需加载。这是完全正常的——实际上没有迹象表明您问题中的那条消息有任何问题。