在CoreData的UserInfo字典 [英] UserInfo Dictionaries on CoreData
问题描述
什么是苹果公司的核心数据文档的这一部分意味着什么?
What does this part of Apple core data documentation means?
用户信息字典
许多管理对象模型的实体元素,属性和关系都具有的相关用户信息字典。你可以把你想要的任何信息到用户信息的字典,作为键 - 值对。装进用户信息字典共用信息包括为获取财产使用的predicate一个实体版本的详细信息,和值。
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.
据我所知,在默认情况下的实体有字典,但我无法找到找到USERINFO上coredata实体或属性。
I understand that by default entities have that dictionary, but I'm not able to find find userInfo on coredata entities or attributes.
推荐答案
获得 NSEntityDescription
从 NSManagedObject
(通过实体
属性)或从 NSManagedObjectModel
并通过attributesByName得到NSAttributeDescription。这给了你,你得到的名字正确的描述,有 USERINFO
作为一个属性为好。
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"];
这篇关于在CoreData的UserInfo字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!