从IOS应用程序访问Core Data中的“用户信息”字典

时间:2014-07-15 10:28:37

标签: ios core-data ios7

我已经创建了一些ManagedObjects,并为每个人添加了用户信息 DisplayName

的键值/值

示例:

       Attribute: eReader
   User Info Key: DisplayName
 User Info Value: E-Reader

      Attribute: weather 
  User Info Key: DisplayName
User Info Value: Weather Radar

我希望从代码中查询整个 NSManagedObject ,然后遍历每个属性并在屏幕上显示 DisplayName 。关于如何做到这一点的任何指导?

这样我就可以显示一个User Readable文本表,但每个条目都映射到正确的NSManagedObject属性,该属性不能以大写字母开头或者在其中有空格。

1 个答案:

答案 0 :(得分:0)

我在UserInfo Dictionaries on CoreData

找到了答案
for (NSString *key in [ei.attributesAsDictionary allKeys]) {
    NSAttributeDescription *attributeDescription = eiEd.attributesByName[key];
    NSString *displayName = attributeDescription.userInfo[@"DisplayName"];
}