i am passing data from one view to the other using xml parser.when i click on any row(after the xml is loaded on the view) it should display the entire details accordingly.
– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UILabel *titleLabel = nil;
UILabel *priceLabel = nil;
UILabel *titleValueLabel = nil;
UILabel *priceValueLabel = nil;
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 20)];
titleLabel.text = @"Model:";
priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, 50, 20)];
priceLabel.text = @"Price:";
priceValueLabel = [[UILabel alloc] initWithFrame:CGRectMake(120, 20, 50, 20)];
titleValueLabel = [[UILabel alloc]initWithFrame:CGRectMake(120, 1, 320, 20)];
[cell.contentView addSubview:titleLabel];
[cell.contentView addSubview:priceLabel];
[cell.contentView addSubview:titleValueLabel];
[cell.contentView addSubview:priceValueLabel];
}
NSDictionary *tempProduct = [self.listData objectAtIndex:indexPath.row];
NSDictionary *productTitle = [tempProduct valueForKey:TITLE];
NSString *titleValue = [productTitle valueForKey:TEXT];
titleValue = [titleValue stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
titleValueLabel.text = titleValue;
[cell.contentView addSubview:titleValueLabel];
NSDictionary *productPrice = [tempProduct valueForKey:PRICE];
NSString *priceValue = [productPrice valueForKey:TEXT];
priceValue = [priceValue stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
priceValueLabel.text = priceValue;
[cell.contentView addSubview:priceValueLabel];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
and my sample xml data is
<?xml version="1.0" encoding="UTF-8"?>
<scan>
<products>
<title>samsung galaxy</title>
<desc>smart phone</desc>
<price>250$</price>
</products>
<products>
<title>samsung galaxy1</title>
<desc>smart phone1</desc>
<price>251$</price>
</products>
<products>
<title>samsung galaxy2</title>
<desc>smart phone2</desc>
<price>252$</price>
</products>
<products>
<title>samsung galaxy3</title>
<desc>smart phone3</desc>
<price>350$</price>
</products>
</scan>
when i click on the first row,it should display the same data.but it is displaying in the order of the selection.
how to fix this?
you can just passing index like that
EDIT