gpt4 book ai didi

ios - CoreData 关系内容不持久

转载 作者:行者123 更新时间:2023-11-29 02:13:10 25 4
gpt4 key购买 nike

enter image description here

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

这是我如何添加关系的代码

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

关于ios - CoreData 关系内容不持久,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29061021/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com