'valueForUndefinedKey' when the 'key' accessor already exists (part deux)
'valueForUndefinedKey' when the 'key' accessor already exists (part deux)
- Subject: 'valueForUndefinedKey' when the 'key' accessor already exists (part deux)
- From: "Frederick C. Lee" <email@hidden>
- Date: Thu, 6 Apr 2006 10:29:12 -0700
Scenario:
[MapManagedObject] --->> [MapCoordinates]
(MapManagedObject) I/O appears to work okay if I don't access the
child (MapCoordinates) MO file:
[Session started at 2006-04-06 10:11:23 -0700.]
{MapManagedObject.m: image}
{MapManagedObject.m: image}
*** Saved *** <-- Okay
But when I create and save the Map's Coordinates (MapCoordinates MO)
as per following code:
===============
- (NSManagedObject *)newMapCoordinates:(NSDictionary *)inData {
NSManagedObject *mcManagedObject =
[[[MapManagedObject alloc] initWithEntity:[[managedObjectModel
entitiesByName] valueForKey: @"MapCoordinates"]
insertIntoManagedObjectContext: managedObjectContext]
autorelease];
float x = [[inData valueForKey:@"x"] floatValue];
float y = [[inData valueForKey:@"y"] floatValue];
NSString *coordString = NSStringFromPoint(NSMakePoint(x,y));
[mcManagedObject setValue:@"One" forKey:@"name"];
[mcManagedObject setValue:coordString forKey:@"coordString"];
return mcManagedObject;
} // end newMapCoordinates().
//
------------------------------------------------------------------------
------------------------------------------------------------------------
---
- (void)loadMapCoordinates:(NSNotification *) notice {
NSLog(@"{EWAppDelegate.m: loadMapCoordinates}");
@try {
MapManagedObject *currentMap = [[ewBrowserMapArrayController
selectedObjects] objectAtIndex:0];
NSManagedObject *newCoords = [[self newMapCoordinates:
[notice userInfo]] retain];
// Attaching the MapCoord link to parent 'Map':
NSMutableSet *MapCoordSet = [currentMap
mutableSetValueForKey:@"mapcoordinates"];
[MapCoordSet addObject:newCoords];
[newCoords release];
}
@catch (NSException *e) {
NSLog(@"{EWAppDelegate.m: loadMapCoordinates} %@",e);
}
[self activateMapCoordSheet:nil];
}
===============
I get the following upon SAVE:
{EWAppDelegate.m: loadMapCoordinates}
*** {MapManagedObject.m: valueForUndefinedKey} key = image***
{EWAppDelegate.m:sheetPanelExit} (tag = 700) [<MapManagedObject
0x64b7f0>
setValue:forUndefinedKey:]: this class is not key value coding-
compliant for the key imageData.
===============
Note again: 'image' and 'imageData' have accessors within
MapManagedObject.
So somehow, programmatically adding a child MO instance to the MOC
and populating it, causes the runtime error upon SAVE.
Any clues?
Ric.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden