我有以下For循环,循环遍历Core Data实体,然后检查一个名为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.
}
}
问题在于Exhibitor.attribute = value。我需要以某种方式参考参展商的属性对象。有人可以帮忙吗?
答案 0 :(得分:0)
MO与键值兼容。这样:
[exhibitor setValue:value forKey:attribute];