• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
'valueForUndefinedKey' when the 'key' accessor already exists ... *SOLVED!*
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

'valueForUndefinedKey' when the 'key' accessor already exists ... *SOLVED!*


  • Subject: 'valueForUndefinedKey' when the 'key' accessor already exists ... *SOLVED!*
  • From: "Frederick C. Lee" <email@hidden>
  • Date: Fri, 7 Apr 2006 15:02:17 -0700

Scenario:
[Map (MapManagedObject)]  ---->> [MapCoordinates (NSManagedObject)].

I finally solved the problem.
It was something that only I could have found: a typo.

I had allocated 'MapManagedObject' {ref: [MapManagedObject alloc]}
for a NSManagedObject by mistake:

- (NSManagedObject *)newMapCoordinates:(NSDictionary *)inData {
NSManagedObject *mcManagedObject =
[[[MapManagedObject alloc] initWithEntity:[[managedObjectModel entitiesByName] valueForKey: @"MapCoordinates"]
insertIntoManagedObjectContext: managedObjectContext] autorelease];
....
....
....


    return mcManagedObject;

} // end newMapCoordinates().

==========

The correct stmt is:
...
NSManagedObject *mcManagedObject =
[[[NSManagedObject alloc] initWithEntity:[[managedObjectModel entitiesByName] valueForKey: @"MapCoordinates"]
insertIntoManagedObjectContext: managedObjectContext] autorelease];
...


==========

What I got for the misery: attempting to encode an entire MO vs a MO's attribute.
Who could have guess the cause of the run-time error?


I found this typo via rebuilding the project from scratch.

Ric.


Scenario:
Map --->> MapCoordinates

Abstract:
The MapManagedObject can get updated (with images) WITHOUT errors, IF I DONT
ADD ANY CHILDREN (coordinates). Otherwise, the runtime complains of a missing
(image) accessor that actually does exist in the MapManagedObject.


If it helps to clarify anything, I re-wrote 'loadMapCoordinates ()' (#1 vis #2) using
the child ewBrowserMCController via 'addObject':


[...]

The outcome is still the same:

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


  • Prev by Date: Re: testing a cocoa widget
  • Next by Date: Newbie Question about using selected file name with fopen
  • Previous by thread: Re: testing a cocoa widget
  • Next by thread: Getting NSData out of an NSImage
  • Index(es):
    • Date
    • Thread