我遇到了核心數據值發生更改的問題,因爲我不打算這樣做。我有一個關於如何解決它的想法,但每次我都會遇到無法識別的選擇器。我的想法是將valueArray = attribute.values;
更改爲valueArray = [NSArray arrayWithArray:attribute.values];
任何幫助,將不勝感激。CoreData的值意外更改
編輯:我想創建一個總和的attribute.values。我有技能節點,每個都有附加的屬性,有時這些屬性值是不同的。我試圖總結所有類似的價值觀。
Build *selectedBuild = [buildListController selectedObjects][0];
NSMutableDictionary *attributeAggregator = nil;
attributeAggregator = [NSMutableDictionary dictionary];
NSLog(@"Before: %@", attributeAggregator);
NSMutableDictionary *numValues = [NSMutableDictionary dictionary];
NSArray *valueArray = nil;
for (SkillNode *active in selectedBuild.activeNodes) {
for (Attribute *attribute in active.attributes) {
NSString *attrName = attribute.name;
NSLog(@"%@ %@", attribute.name, attribute.values);
NSMutableArray *obj = [attributeAggregator objectForKey:attribute.name];
if (obj) {
for (int ndx = 0; ndx < [obj count]; ndx++) {
obj[ndx] = [NSNumber numberWithFloat:([obj[ndx] integerValue] + [attribute.values[ndx] integerValue])];
}
[attributeAggregator setValue:obj forKey:attrName];
} else {
valueArray = attribute.values;
[attributeAggregator setValue:valueArray forKey:attrName];
[numValues setValue:attribute.numValues forKey:attrName];
}
}
}
什麼是無法識別的選擇器錯誤? – propstm
發送消息給釋放對象。它無法在指定的內存中找到該對象。 – stormbard