在CoreData的UserInfo字典 [英] UserInfo Dictionaries on CoreData

查看:215
本文介绍了在CoreData的UserInfo字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是苹果公司的核心数据文档的这一部分意味着什么?

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆