views:

292

answers:

1

Hi, I have the following error while trying to call the save method on managedObjectContext.

#0  0x939214e6 in objc_exception_throw
#1  0x01ded83b in -[NSObject doesNotRecognizeSelector:]
#2  0x01d84676 in ___forwarding___
#3  0x01d606c2 in __forwarding_prep_0___
#4  0x01c618b6 in -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:]
#5  0x0003263a in _nsnote_callback
#6  0x01d4f005 in _CFXNotificationPostNotification
#7  0x0002fef0 in -[NSNotificationCenter postNotificationName:object:userInfo:]
#8  0x01bc217d in -[NSManagedObjectContext(_NSInternalNotificationHandling)     _postObjectsDidChangeNotificationWithUserInfo:]
#9  0x01c21763 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:]
#10 0x01ba65ea in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:]
#11 0x01bdc728 in -[NSManagedObjectContext save:]
  • I did some changes to the OrderItem entity before coming to this following code, where I want to cancel any insertion to OrderItem

    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    [fetchRequest setEntity:[NSEntityDescription entityForName:@"OrderItem" inManagedObjectContext:managedObjectContext]];
    NSArray *deleteItems = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
    for (id item in deleteItems)
        [managedObjectContext deleteObject:item];
    
    
    if (![managedObjectContext save:&error]){
        NSLog(@"deleting OrderItem failed: %@, %@", error, [error userInfo]);
        return FALSE;
    }
    

The error occurs on the line [managedObjectContext save:&error] without going to the NSLog but raises an exception.

What am I doing wrong? Someone show me how, please?

A: 

I have the complex schema in my .xcdatamodel in which the OrderItem has two relationships with the DeleteRule be set to Nullify.

Temporarily change to "No Action" solves the error even though it raises some warnings, but personally I think, xCode should not behave that way. It should populate the values to &error to let me know I have problems with my schema.

Any thoughts about this?

sfa
If you have warnings you MUST clear those warnings because it is quite possible that one of those warnings is causing your issue. Any answer cannot be valid with warnings as a possible issue.
Marcus S. Zarra
hi Marcus, I have not figured out how to solve this error. Do you have some hints to the question or you need me to provide more information in order to give the answer?
sfa