核心数据:从商店获取数据时出现奇怪的崩溃

时间:2023-01-17 16:03:01

Hia, got a one to many relation for chars and items. one char can hold a specific item, same item can be used by others. The CharInfo is defined as follows:

Hia,对于字符和项目有一对多的关系。一个char可以保存特定项目,其他人可以使用相同的项目。 CharInfo定义如下:

@property (nonatomic, retain) ItemInfo * slotEar;

CharInfo.slotEar is a reference to the item. It is optional, min count 1, max count 1 and delete rule Nulify. ItemInfo is defined as:

CharInfo.slotEar是对项目的引用。它是可选的,最小计数1,最大计数1和删除规则Nulify。 ItemInfo定义为:

@property (nonatomic, retain) NSSet* slotEar;

ItemInfo.slotEar is a reference to the char. It is optional, one to many and delete rule Nulify.

ItemInfo.slotEar是对char的引用。它是可选的,一对多并删除规则Nulify。

They are referencing to each other. There is an additional class that works with the data. It does hold the reference as well and provide it for storing.

他们互相引用。还有一个适用于数据的类。它确实保留了引用并提供它用于存储。

ItemInfo *slotEar;

CharInfo get created before saving like this:

在保存之前创建CharInfo,如下所示:

When I save the CharInfo, I set the ItemInfo (from my structure) in the aproviate slot.

当我保存CharInfo时,我在aproviate槽中设置了ItemInfo(来自我的结构)。

    CharInfo *charInfo = [NSEntityDescription
                      insertNewObjectForEntityForName:@"CharInfo" 
                      inManagedObjectContext:managedObjectContext];
charInfo.slotEar = currentChar.slotEar;

Saving the context works.

保存上下文有效。

When I try to load the CharInfo from store, it works most of the time from now. After relaunching he does crash at this line.

当我尝试从商店加载CharInfo时,它从现在起大部分时间都在工作。重新启动后,他确实崩溃了。

curentChar.slotEar = charInfo.slotEar;

If there was no item reference (nil) then all is fine.

如果没有项目参考(零)那么一切都很好。

Unfortunately the crash is more a halt. No error is given, he just stops at that line in the debugger and the green description next to the link says: EXC_BAD_ACCESS

不幸的是,崩溃更加停顿。没有给出错误,他只是停在调试器中的那一行,链接旁边的绿色描述说:EXC_BAD_ACCESS

Seems something is wrong with the reference I save or the way how I try to take it from the CharInfo to my class. Any idea?

似乎我保存的引用或我尝试将它从CharInfo带到我的类的方式有问题。任何想法?

Screenshot added: 核心数据:从商店获取数据时出现奇怪的崩溃

截图添加:

1 个解决方案

#1


0  

No bug with core data or the worker class ivars, but with an int array with 6 ints filled with 100 ints.

核心数据或工人类ivars没有错误,但是带有6个int的int数组填充了100个int。

#1


0  

No bug with core data or the worker class ivars, but with an int array with 6 ints filled with 100 ints.

核心数据或工人类ivars没有错误,但是带有6个int的int数组填充了100个int。