Today, my core data suddenly stopped working. You must see this:
So basically I have a Task
NSManagedObject, which has a medias
to-many relationship.
Originally I was using task.medias.count
to get the count of the medias. And it has been working from the beginning.
Since the problem happened, I tried several things.
1) Change to code to a try-catch block:
NSInteger mCount;
@try {
NSSet *myMedias= task.medias;
mCount = myMedias.count; <<<===this is the line that debug stops and value flashes in the variable view as shown in the picture.
}
@catch (NSException *exception) {
NSLog(@"%@", exception);
...
}
But it doesn't work, the debugger still stop at mCount line, and that's what is shown in gif.
2) I look into the .xcdatamodeld
file, and I found that medias
relationship has accidentally put a minimum of 1 count. I toggled that off(see picture). But problem persists.
3) I am using StackMob as backend. When I turn off the network, the flash stops. It seems that core data is trying to fire the fault but couldn't complete it's job. Or something is preventing it from finishing.
4)The error code was:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'nil is not a valid object ID'
==========
Does anyone here knows what happened and how to solve this?