views:

127

answers:

1

For any given NSManagedObject, is there any method to return a set or array of keys (attribute names) for that particular NSManagedObject? I've tried looking around in NSObject & NSManagedObject docs but found nothing. Something that functions like NSDictionary 'allKeys' would be what I need, ie.

myArrayOfKeys = [myDict allKeys]

I presume there must be an easier way of handling large numbers of attributes eg. iterating over an array of keys.

+3  A: 

-[NSManagedObject entity] returns the NSEntityDescription. This then lets you find its properties, in particular if you just want the attribute names you can get -[NSEntityDescription attributesByName], a dictionary where each key is an attribute name and each value is a NSAttributeDescription.

Graham Lee