开发者

pass specific attribute of an object stored in an array to a TableView cell

So I have an array with objects which each have several attributes including an image, title, subtitle, etc. I would like to put each object into a cell. I know I will have to format the cells to contain all开发者_开发知识库 the different attributes, but for starters, how could I put just the title of each object into the cell. If I had just a string array of titles it would be as easy as doing this inside the cellForRowAtIndexPath method:

cell.textLabel.text = [myTitlesArray objectAtIndex:indexPath.row];

but since it's an object array how do I do this?

I've tried:

cell.textLabel.text = [myObjectsArray.title objectAtIndex:indexPath.row];

... and several other placements of .title which is probably ridiculous to even try. Is there a way to do this without making splitting each object into separate arrays of attributes or something hacky like that?


you probably need to do it this way:

cell.textLabel.text = [[myObjectsArray objectAtIndex:indexPath.row] title];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜