-[_NSControllerObjectProxy entity]: unrecognized selector sent to instance
-[_NSControllerObjectProxy entity]: unrecognized selector sent to instance
- Subject: -[_NSControllerObjectProxy entity]: unrecognized selector sent to instance
- From: Daniel Child <email@hidden>
- Date: Wed, 25 Feb 2009 14:43:22 -0500
Hi All,
I am trying to add an object in a to-many relationship and get this
error:
-[_NSControllerObjectProxy entity]: unrecognized selector sent to
instance <the instance>
The object I'm adding was obtained by using
NSManagedObject *theWord = [wordList selection]
This yields a proxy object instead of an MO. (Does anyone know why?)
If I obtain the object using:
*theWord = [[wordList selectedObjects] objectAtIndex: 0];
then when I try to add the Word to my "relatedWords" relationship to
character, I instead get this error.
-[NSManagedObject copyWithZone:]: unrecognized selector sent to
instance 0x1adf50
I simply don't see what I've done wrong. Here is the code. Thanks for
looking....
- (IBAction) relateSelectedWordToConstituentCharacters: (id) sender
{
NSManagedObjectContext *moc = [self managedObjectContext];
// NSManagedObject *theWord = [wordList selection]; // PROBLEM HERE
(yields proxy object!!! not MO / unclear why)
NSManagedObject *theWord = [[wordList selectedObjects] objectAtIndex:
0]; // OR HERE (causes mutable copy error below)
NSManagedObject *charObject;
NSMutableSet *relatedWords;
NSString *wordAsString = [theWord valueForKey: @"compound"];
NSMutableArray *constituentChars =
getConstituentCharacters(wordAsString);
BOOL charExists;
for (NSString *oneChar in constituentChars) {
charExists = characterExistsInCharacterEntity(oneChar);
if (!charExists) {
charObject = [NSEntityDescription insertNewObjectForEntityForName:
@"Characters" inManagedObjectContext: moc];
[charObject setValue: oneChar forKey: @"character"];
}
else {
charObject = getCharObject(oneChar); // function to execute the
fetch based on the oneChar string
}
relatedWords = [charObject mutableSetValueForKey: @"words"];
[relatedWords addObject: theWord]; // mutable copy error here
// NEED TO SAVE CHANGES TO MOC HERE ONCE IT WORKS....
}
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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