2011-09-22 59 views
0

更新此主题,因为我有一些其他的帮助解决,为什么我不能够访问方法外NSDictionarys值...更新:不能通过的NSDictionary到的UITableViewCell为textLabel

我initalizing错从而自动释放了被称为在该方法的结尾,所以当我在该方法之外调用它时,我得到各种各样的错误..

所以现在基本上我试图分配NSDictionarys值到UITableViewCell文本里面cellForRowAtIndexPath但是我我得到这个错误

这里是我如何尝试在这一点上

// 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; 

分配,并输出.OUTPUT

2011-09-23 10:25:01.343 Code[6796:207] thingy (
    Honda, 
    Honda, 
    Honda, 
    Honda, 
    Honda, 
    Honda, 
    Honda 
) 
然而

,如果我注释掉//Cell.textLabel.text = value;我得到这个输出

.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 
) 
+0

你能发布你的界面(.h)文件吗? –

+0

提供.h文件显示arraysByLetter的声明。谢谢:) –

+0

我想这需要问...你绝对确定startSortingTheArray被称为BEFORE cellForRowAtIndexPath? –

回答

1

你知道什么,我想我知道这个问题,所以我要猜测。

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

至少,我一直在使用self.property,所​​以我不记得这是必要的还是仅仅是一种习惯。给那一枪。

+0

arrrr !!!是的,我认为你可能是对的..我早些时候尝试使用[self arraysByLetter],但没有工作!真是个傻瓜!多数民众赞成你如何称呼一种方法:现在试试看。手指交叉。 –

+0

该死的这没有工作... IM即时张贴我的.h文件。 –

+0

[self arraysByLetter]是getter。 如果你想使用消息发送使用[self setArraysByLetter] –

相关问题