Apple 核心数据文档的这一部分是什么意思?
What does this part of Apple core data documentation means?
用户信息词典
托管对象模型中的许多元素(实体、属性和关系)都有关联的用户信息字典.您可以将所需的任何信息作为键值对放入用户信息字典中.放入用户信息字典的通用信息包括实体的版本详细信息,以及用于获取属性的谓词的值.
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.
我了解默认情况下实体具有该字典,但我无法在 coredata 实体或属性上找到 userInfo.
I understand that by default entities have that dictionary, but I'm not able to find find userInfo on coredata entities or attributes.
从 NSManagedObject
获取 NSEntityDescription
(通过 entity
属性)或从您的 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 字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!