Re: Core Data data access
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