I've researched the site and other sources online, but couldn't find a direct addressing to what I am asking. I have the following code in my class:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableCell";
KJCustomAdTableCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (!cell) {
[tableView registerNib:[UINib nibWithNibName:@"CustomerAdCell" bundle:nil] forCellReuseIdentifier:@"myCustomCell"];
cell = [tableView dequeueReusableCellWithIdentifier:@"myCustomCell"];
}
//cell.textLabel.text = [_adsObjectArray objectAtIndex:indexPath.row];
// AdObject *someAd = _adsObjectArray[0];
// cell.titlePl aceholderLabel.text = someAd.title;
// cell.locationPlaceholderLabel.text = someAd.location;
return cell;
}
When I tried this with an array of strings, it worked well and I could get a table with all items in the array. But when I tried with my array of AdObjects, it didn't work. I tried a for loop to go through the array, but learned that this method is called for creation of each cell row, hence caused my whole table to reflect the same title for all rows.
I seek your help or a tutorial/question in another location that would address this problem...
Thanks in advance!
_adsObjectArray[0]instead of_adsObjectArray[indexPath.row]?AdObject *someAd = [_adsObjectArray objectAtIndex:[indexPath row]]; cellTitlePlaceholderLabel.text = someAd.title;