NSManagedObjectContext save doesn't crash but breaks on objc_exception_throw

后端 未结 5 861
一向
一向 2021-01-05 10:23

I am having the same issue described at this address http://www.cocoabuilder.com/archive/cocoa/288659-iphone-nsmanagedobjectcontext-save-doesn-crash-but-breaks-on-objc-excep

5条回答
  •  盖世英雄少女心
    2021-01-05 11:16

    Looking at this answer reveals that CoreData internally uses exceptions to manage their program flow. Thats why the debugger breaks at objc_exception_throw. As far as I know there is no way to disable this.

    EDIT: Since then, there is now a solution to ignore these exceptions: Ignore certain exceptions when using Xcode's All Exceptions breakpoint

    BTW: Do not check on error but use the returned BOOL value to ensure success of your save call. The correct way of doing this would be:

    NSError *error = nil;
    BOOL success = [self.managedObjectContext save:&error];
    if (!success) {
        NSLog(@"Error : %@",error);
    }
    

提交回复
热议问题