Alex Rivera | Logout

Core Data Relationships cause save error after delete

Asked 2009-09-23T00:42:38.903
23

This question is probably a long shot. I can't figure out the errors I'm getting on my core data project when I save after I delete an entity.

I have two main entities that I work with, an Outfit, and an Article. I can create them with no problem but when I delete them I get the follow error log:

For the Outfit:

2009-09-22 20:17:37.771 itryiton[29027:20b] Operation could not be completed. (Cocoa error 1600.)
2009-09-22 20:17:37.773 itryiton[29027:20b]   {
    NSLocalizedDescription = "Operation could not be completed. (Cocoa error 1600.)";
    NSValidationErrorKey = outfitArticleViewProperties;
    NSValidationErrorObject = <Article: 0x12aa3c0> (entity: Article; id: 0x12b49a0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/Article/p1> ; data: {
    articleID = 2009-09-22 19:05:19 -0400;
    articleImage = 0x12b4de0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/ArticleImage/p1>;
    articleType = nil;
    attributeTitles = "(...not nil..)";
    color = nil;
    comment = nil;
    dateCreated = 2009-09-22 19:05:19 -0400;
    designer = nil;
    imageView = "(...not nil..)";
    location = "(...not nil..)";
    outfitArticleViewProperties =     (
        0x12b50f0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/OutfitArticleViewProperties/p1>
    );
    ownesOrWants = 0;
    pattern = nil;
    price = nil;
    retailer = nil;
    thumbnail = "(...not nil..)";
    washRequirements = nil;
    wearableSeasons = nil;
});
    NSValidationErrorValue =     {(
        <OutfitArticleViewProperties: 0x1215340> (entity: OutfitArticleViewProperties; id: 0x12b50f0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/OutfitArticleViewProperties/p1> ; data: {
    article = 0x12b49a0 <x-coredata://7046DA47-FCE1-4E21-8D7B-E532AAC0CC46/Article/p1>;
    articleViewPropertiesID = nil;
    outfit = nil;
    touch = nil;
    view = "(...not nil..)";
})
    )};
}

And if I delete an Article

Edit
Report

2 Answers

2

Check your xcdatamodel file for a Deny delete rule. Click on each relationship until you find it. You'll need to change this rule or adjust how you delete managed objects to anticipate the rule's application to the relationship.

answered 2009-09-23T00:46:33.743
0

In my case I have innocently created custom method in my subclass of NSManagedObject: isDeleted. I was encountering strange save exceptions until I removed / renamed it. After losing my sanity, I read documentation again more through-fully this time. It turned out I overridden one of the NSManagedObject methods one MUST NOT OVERRIDE.

Check if this excerpt from docs helps you:

Methods you Must Not Override

NSManagedObject itself customizes many features of NSObject so that managed objects can be properly integrated into the Core Data infrastructure. Core Data relies on NSManagedObject’s implementation of the following methods, which you therefore absolutely must not override: primitiveValueForKey:, setPrimitiveValue:forKey:, isEqual:, hash, superclass, class, self, isProxy, isKindOfClass:, isMemberOfClass:, conformsToProtocol:, respondsToSelector:, managedObjectContext, entity, objectID, isInserted, isUpdated, isDeleted, and isFault, alloc, allocWithZone:, new, instancesRespondToSelector:, instanceMethodForSelector:, methodForSelector:, methodSignatureForSelector:, instanceMethodSignatureForSelector:, or isSubclassOfClass:.

Besides - there are other methods you can override but you MUST CALL super implementation like or call: willAccessPrimitiveForKey, didAccessPrimitiveForKey in accessors and willChangevalueForKey, didChangeValueForKey in setters....

answered 2013-02-12T14:28:33.253

Your Answer