【发布时间】:2013-12-19 02:40:27
【问题描述】:
所以我将一个类对象插入到 NSMutable 数组中,然后我尝试管理每个索引对象的特定属性。
在这里我创建了 NsMutableArray:
self.currentPuzzle = [[NSMutableArray alloc]init];
for(int i = 0; i < [temp length]; i++){ //temp is a string containing #'s and dots.
AnswerSpecifier *objectToGetIntoArray = [[AnswerSpecifier alloc]init];
objectToGetIntoArray.value = [[temp substringWithRange:NSMakeRange(i, 1)] intValue];
[self.currentPuzzle addObject:objectToGetIntoArray];
}
在这里我试图更改每个对象的 value 属性。 value 是一个 int 属性。
for (int i = 0; i < [self.board.boardString length]; i++) {
[self.currentPuzzle objectAtIndex:i].value = [[self.board.boardString substringWithRange:NSMakeRange(i, 1)] intValue];
}
但是我收到一条错误消息,指出在 id 类型的对象上找不到属性值。我应该创建一个新数组并将其分配给旧数组吗?有没有更好的方法来做到这一点?
【问题讨论】:
标签: ios objective-c cocoa-touch