开发者

UPDATED: cannot pass NSDictionary to UITableViewCell textlabel

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

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..

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;

.output

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

however, if I开发者_如何学Python 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.

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

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜