【问题标题】:Save Core Data Attribute from a For Loop - iOS从 For 循环中保存核心数据属性 - iOS
【发布时间】:2013-09-26 13:50:32
【问题描述】:

我有以下 For 循环,它遍历核心数据实体,然后检查名为 keyString 的 NSString 是否与属性匹配。如果它确实匹配,那么我想将该实体上的属性设置为另一个名为 value 的 NSString:

NSEntityDescription *entity = [exhibitor entity];
    NSDictionary *attributes = [entity attributesByName];
    for (NSString *attribute in attributes) {
        if ([keyString isEqualToString:attribute]) {
            exhibitor.attribute = value; //This bit is wrong.
        }
    }

问题在于existor.attribute = value 这一行。我需要以某种方式引用参展商的属性对象。有人可以帮忙吗?

【问题讨论】:

    标签: ios objective-c xcode core-data nsdictionary


    【解决方案1】:

    MO 是键值兼容的。所以:

    [exhibitor setValue:value forKey:attribute];

    【讨论】:

      猜你喜欢
      • 2021-09-22
      • 2020-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      相关资源
      最近更新 更多