0

I am parsing RSS to UITableview and the data looks as it should but when I select one of the field in the UITableview it opens different data then what it should. Also when I scroll the tableview the same field that I have selected gives again different data.

So please where could I made my mistake?

The RSS link: http://www.luaikalkatawi.me/picksound

Thanks from now.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    NSString *trimed = [[containerObject.track init] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

    NSLog(@"The link is %@", trimed);
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* cellIdentifier = @"ImgCell";

ImgCell *cell = (ImgCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];

if (cell == nil)
{
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:cellIdentifier owner:nil options:nil];
    cell = (ImgCell*)[nib objectAtIndex:0];
}

containerObject = [objectCollection objectAtIndex:indexPath.row];//use the common object again for holding the corresponding array object

///// Image reloading from HJCacheClasses
[cell.img clear];
NSString *str1 = containerObject.image; //we use image property of rss object to set the image
NSString *trimmedString = [str1 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSURL *url = [NSURL URLWithString:trimmedString];
cell.img.url = url; //set the url to img view
[self.imgMan manage:cell.img];

cell.mainText.text = containerObject.title; //title member variable for setting title
cell.detailText.text = containerObject.description;//desc variable foe
return cell;
}
Luai Kalkatawi
  • 1,492
  • 5
  • 25
  • 51
  • How are you updating your containerOject.track selection ? – Lefteris Dec 06 '12 at 12:21
  • may be the problem is with How you load data into the table view cell (scroll the tableview as pointed out in ur question). I suggest U to add code for - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath in Question – Pranav Jaiswal Dec 06 '12 at 12:27
  • @Lefteris Thanks for the respond. I have added the code if it is not enough I will add all the code in a shareable sheet here. – Luai Kalkatawi Dec 06 '12 at 12:46

1 Answers1

0

I don't know why this is confusing to you, but the correct containerObject, should be accessed in the didSelectRowAtIndexPath.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    containerObject = [objectCollection objectAtIndex:indexPath.row];
    NSString *trimed = [[containerObject.track init] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

    NSLog(@"The link is %@", trimed);
}
Lefteris
  • 14,550
  • 2
  • 56
  • 95