更新此线程,因为我有其他一些帮助解决了为什么我无法访问方法外部的 NSDictionarys 值...
我初始化错误,因此在方法结束时调用了 autorelease,因此当我在该方法之外调用它时,我遇到了各种错误..
所以现在基本上我正在尝试将 NSDictionarys 值分配给 cellForRowAtIndexPath 内的 UITableViewCell Text,但是我收到此错误
这是我尝试分配它的方式以及此时的输出
// Configure the cell...
if(indexPath.row <= [self.sectionLetters count]){
// NSObject *key = [self.sectionLetters objectAtIndex:indexPath.row];
NSString *value = [self.arraysByLetter objectForKey:[self.sectionLetters objectAtIndex:indexPath.row]];
NSLog(@"thingy %@", value);
cell.textLabel.text = value;
}
return cell;
.输出
2011-09-23 10:25:01.343 Code[6796:207] thingy (
Honda,
Honda,
Honda,
Honda,
Honda,
Honda,
Honda
)
但是,如果我注释掉 //Cell.textLabel.text = value;
我会得到此输出
.输出2
2011-09-23 10:26:38.322 Code[6876:207] thingy (
Honda,
Honda,
Honda,
Honda,
Honda,
Honda,
Honda
)
2011-09-23 10:26:38.323 Code[6876:207] thingy (
Mazda,
Mazda,
Mitsubishi,
Mitsubishi,
Mitsubishi,
Mitsubishi,
Mitsubishi,
Mitsubishi
)
2011-09-23 10:26:38.325 Code[6876:207] thingy (
Nissan,
Nissan,
Nissan,
Nissan,
Nissan,
Nissan,
Nissan
)
2011-09-23 10:26:38.326 Code[6876:207] thingy (
Toyota,
Toyota,
Toyota
)
最佳答案
你知道吗,我想我知道问题所在,所以我要做出猜测。
因为您直接使用 arraysByLetter,所以我不相信您会遇到合成属性,而是会遇到支持变量。您需要使用 self.arraysByLetter (这将保留字典)。
至少,我一直在使用 self.property,所以我不记得这是必要的还是只是一种习惯。试一试。
关于iphone - 更新: cannot pass NSDictionary to UITableViewCell textlabel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7509160/