Core Data: odd crash when getting data from store
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:
@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:
@property (nonatomic, retain) NSSet* slotEar;
ItemInfo.slotEar is a reference to the char. It is optional, one to many and delete rule 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:
When I save the CharInfo, I set the ItemInfo (from my structure) in the aproviate slot.
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.
curentChar.slotEar = charInfo.slotEar;
If there was n开发者_StackOverflow社区o 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
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?
Screenshot added:
No bug with core data or the worker class ivars, but with an int array with 6 ints filled with 100 ints.
精彩评论