Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UserInfo Dictionaries on CoreData

What does this part of Apple core data documentation means?

User Info Dictionaries

Many of the elements in a managed object model—entities, attributes, and relationships—have an associated user info dictionary. You can put whatever information you want into a user info dictionary, as key-value pairs. Common information to put into the user info dictionary includes version details for an entity, and values used by the predicate for a fetched property.

I understand that by default entities have that dictionary, but I'm not able to find find userInfo on coredata entities or attributes.

like image 240
drasick Avatar asked Jun 21 '13 08:06

drasick


Video Answer


1 Answers

Get the NSEntityDescription from your NSManagedObject (through the entity property) or from your NSManagedObjectModel and get the NSAttributeDescription through attributesByName. This gives you a dictionary where you get the proper Description by name which has the userInfo as a property as well.

NSManagedObject *managedObject;
NSEntityDescription *entityDescription = managedObject.entity;
NSAttributeDescription *attributeDescription = entityDescription.attributesByName[@"someAttribute"];
NSString *foo = attributeDescription.userInfo[@"foo"];
like image 73
Karl Avatar answered Oct 19 '22 04:10

Karl