• 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
Re: Core Data data access
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data data access


  • Subject: Re: Core Data data access
  • From: Scott Ellsworth <email@hidden>
  • Date: Thu, 30 Mar 2006 12:10:19 -0800


On Mar 30, 2006, at 11:31 AM, Dan Grassi wrote:

NSLog(@"PropertyName : %@", [managedObject valueForKey:@"PropertyName"]);

I get:
2006-03-30 14:28:24.440 ProjectName[11524] Exception raised during posting of notification. Ignored. exception: [<NSManagedObject 0x3e0510> valueForUndefinedKey:]: this class is not key value coding-compliant for the key PropertyName.



Which tells you that the class does not have an attribute or relationships named 'propertyName'


You should either pass the managed object itself as the argument to NSLog, or you should iterate over the property names. These can be found in the entity description, IIRC.

e.g. (typed in mail)

NSManagedObject* managedObject;
while (managedObject = [enumerator nextObject]){
NSEntityDescription * description = [managedObject entity];
NSDictionary * attributesByName = [description attributesByName];
NSEnumerator * attributeEnum=[attributesByName keyEnumerator];
NSString * attributeName;
while ( (attributeName = [attributeEnum nextObject]) ) {
NSAttributeDescription * attributeDescription = [attributesByName objectForKey:attributeName];
NSLog(@"name: %@ type:%d value:%@",attributeName, [attributeDescription attributeType],[managedObject valueForKey:@"attributeName"]);
}
}


Surely it must be easy to get the data and even the property names.

The information is there, but in the entity description, rather than in the object itself.


Scott
_______________________________________________
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


References: 
 >Core Data data access (From: Dan Grassi <email@hidden>)

  • Prev by Date: NSView adjustScale: View is scaled but the image remains the same.
  • Next by Date: Re: Opening a window in Core Data application
  • Previous by thread: Re: Core Data data access
  • Next by thread: Opening a window in Core Data application
  • Index(es):
    • Date
    • Thread