I have a simple method that just takes two managed object IDs, pulls the managedObjects for them, makes a relation and then saves them into the managedObjectContext.
When I perform the save on the managedObjectContext, the debugger stops on the save line with an objc_exception_throw referencing the nsmanagedObjectContext save. Although there is no output in the nserror object that is output to give me any details as to why an exception is thrown. It also appears as if this save does work fine, which makes this even more confusing.
Here is the method in question...
- (void)relateLocationToInvite:(NSManagedObjectID *)locationID :(NSManagedObjectID *)inviteID {
NSManagedObject *invite = [self.managedObjectContext objectWithID:inviteID];
NSManagedObject *locationObj = [self.managedObjectContext objectWithID:locationID];
Location *location = (Location *)locationObj;
[invite setValue:location forKey:@"location"];
NSError *error = nil;
if( ![self.managedObjectContext save:&error] ){
NSLog(@"Error relating a location to an invite %@",error);
}
}
If the execution of the application continues after the save:
method without any problem (i.e. without throwing any uncaught exception and without reporting any error), that means the saving operation's implementation has caught the exception and decided to silently ignore it.
Why this happens is unclear: maybe the implementation relies on exceptions to report internal errors (this is not the way Objective-C exceptions should be used but some other languages make more use of exceptions). As long as the exception is caught before it reaches your own code, you should not worry about it.
If you want to know the reason of the exception, you may break on objc_exception_throw
and use the following debugger command:
po *(id *)($ebp + 8)
This will display the NSException *
parameter given to the function in the iOS Simulator (x86 architecture). On the device (arm architecture), the same result can be achieved using (if my memory serves my correctly):
po $r0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With