Array of NSManagedObject attributes

2 Solutions Collect From Internet About “Array of NSManagedObject attributes”

An NSManagedObject has an entity associated with it. Use NSEntityDescription’s -attributesByName and -relationshipsByName. You’ll get a dictionary back from each of those methods. Just ask the dicts for their -allKeys.

Thanks Joshua. Here’s code that I used in case any one would like to see a hard example:

NSString *entityName = NSStringFromClass([myEntity class]);
NSEntityDescription *entityDescription = [self entityDescriptionWithEntityName:entityName];
NSDictionary *attributes = [entityDescription attributesByName];
NSArray *attributeNames = attributes.allKeys;