I have a User : NSManagedObject
. What's the best way to get an NSAttributeDescription
of it's userID
attribute?
Asked
Active
Viewed 1,157 times
2

ma11hew28
- 121,420
- 116
- 450
- 651
1 Answers
6
Assuming you have access to a User *user
instance, you could do:
NSAttributeDescription *userIDAttribute =
[[user.entity attributesByName] objectForKey:@"userID"];
If you didn't have access to a User *user
object but just to the NSManagedObjectContext *context
, you could get the NSEntityDescription
for User
with:
NSEntityDescription *userEntity = [NSEntityDescription entityForName:@"User"
inManagedObjectContext:context];

ma11hew28
- 121,420
- 116
- 450
- 651