更新:无法将 NSDictionary 传递给 UITableViewCell 文本标签 [英] UPDATED: cannot pass NSDictionary to UITableViewCell textlabel

查看:30
本文介绍了更新:无法将 NSDictionary 传递给 UITableViewCell 文本标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新此线程,因为我有一些其他帮助解决了为什么我无法访问方法之外的 NSDictionarys 值...

Updating this Thread as I have had some other help solving why I was not able to access the NSDictionarys values outside the method...

我初始化错误,因此在方法结束时调用了 autorelease,所以当我在该方法之外调用它时,我遇到了各种错误..

I was initalizing it wrong thus autorelease was being called at the end of the method so when I was calling it outside of that method I was getting all sorts of errors..

所以现在基本上我正在尝试将 NSDictionarys 值分配给 cellForRowAtIndexPath 内的 UITableViewCell 文本,但是我收到此错误

So now basically I am trying to allocate the NSDictionarys values to the UITableViewCell Text inside cellForRowAtIndexPath however I am getting this error

这是我尝试分配它和此时输出的方式

here is how I am trying to allocate it and the output at this point

// 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; 我得到这个输出

however, if I comment out //Cell.textLabel.text = value; I get this output

.output2

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
)

推荐答案

你知道吗,我想我知道问题所在,所以我要猜测一下.

You know what, I think I know the problem so I'm going to make a guess.

因为您直接使用 arraysByLetter,所以我不相信您正在使用合成属性,而是使用了支持变量.您需要使用 self.arraysByLetter(这将保留字典).

Because you're using arraysByLetter directly, I don't believe you're hitting the synthesized properties, but the backing variable instead. You need to use self.arraysByLetter (this will retain the Dictionary).

至少,我一直在使用 self.property,所​​以我不记得这是必需品还是只是习惯.试一试.

At least, I've been using self.property forever, so I can't remember if this was a necessity or just a habit. Give that a shot.

这篇关于更新:无法将 NSDictionary 传递给 UITableViewCell 文本标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆