iphone - 更新: cannot pass NSDictionary to UITableViewCell textlabel

标签 iphone ios uitableview nsdictionary

更新此线程,因为我有其他一些帮助解决了为什么我无法访问方法外部的 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/

相关文章:

ios - 自定义自定义 Url 方案在 iOS 9 中不起作用

ios - 如何将数组 `UnsafePointer<DSPComplex>` 转换为 float 数组?

iPhone OpenGL ES 2.0 与 Cocos2D 混合给出了意想不到的结果

ios - 如何使用 Skobbler 缩放到 map 上的当前位置

ios - 从 UITableView 中删除行时以 NSException 类型的未捕获异常终止

ios - 如何使用分段控件在一个 TableView 中维护两个自定义单元格?

ios - 选择里面没有选择文本的textView?

iphone - iOS:用于调试构建的可选代码片段

iphone - 录音时如何隐藏iOS状态下的红条?

从终端进行 iPhone 静态代码分析未能找到丢失的 ivar 版本