Crash using mutableSetValueForKeys
Crash using mutableSetValueForKeys
- Subject: Crash using mutableSetValueForKeys
- From: Julio Cesar Silva dos Santos <email@hidden>
- Date: Fri, 9 Feb 2007 09:42:32 -0200
Hi,
I have received a crash report from a user of my application
(FetchYourLyrics) that appears to be related to the way I set a
relationship between two entities. The lines of the crash report are:
4 com.apple.CoreData 0x940d9c88 -[NSManagedObject
(_NSInternalMethods)
_maintainInverseNamed:isToMany:oldDestination:newDestination:] + 164
5 com.apple.CoreData 0x940da118 -[NSManagedObject
(_NSInternalMethods)
_didChangeValue:forRelationship:named:withInverse:] + 716
6 com.apple.Foundation 0x92a1b648 -[NSObject
(NSKeyValueObserverNotification)
didChangeValueForKey:withSetMutation:usingObjects:] + 696
7 com.apple.CoreData 0x940d86e4 -[NSManagedObject
didChangeValueForKey:withSetMutation:usingObjects:] + 76
8 com.apple.CoreData 0x940fc804 -
[_NSNotifyingWrapperMutableSet addObject:] + 148
I have two entities, Preference and SearchLanguage. The entity called
SearchLanguage has a relationship prefRelation with the following
attributes: Optional, Destination: Preference, Inverse:
languageRelation. The entity Preference has a relationship
languageRelation with the attributes: Not Optional, Destination:
SearchLanguage, Inverse: prefRelation.
The first time the application launches, the Preference entity is
created with default values loaded from a dictionary file in the
bundle. The SearchLanguage entity is also on this dictionary so I
create it and add it to the relationship using the following code:
//Create the Preference entity
NSManagedObject * prefs = [NSEntityDescription
insertNewObjectForEntityForName:@"Preference" inManagedObjectContext:
[self managedObjectContext]];
// Add the properties for prefs (not shown because I think it is not
related to the crash)
//Create the SearchLanguage entity
NSManagedObject * theLang = [NSEntityDescription
insertNewObjectForEntityForName:@"SearchLanguage"
inManagedObjectContext:[self managedObjectContext]];
//Add the properties for theLang (also not shown)
//Set the relationships
[[prefs mutableSetValueForKey:@"languageRelation"] addObject:theLang];
[theLang setValue:prefs forKey:@"prefRelation"];
This code works fine for me and apparently for anyone that downloaded
the app so far (at least no one has reported that issue). Is there a
problem with my approach? Can you see a reason for this code not work
for a particular user?
Thanks for any help,
Julio Cesar Silva dos Santos
email@hidden
email@hidden
Blogjective-C
http://www.jcs.santos.nom.br/wp
FetchYourLyrics
http://www.jcs.santos.nom.br/fyl/fyl.html
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden