I’m fetching the value from xml. What I’m fetching it’s working good but I face the problem in displaying the value on a cell. I have to display 6 values on first cell and second cell 4 values how can i do this? Because in my first cell, the value is repeated same on next cell.
This is my cell code:
#import <UIKit/UIKit.h>
#import "TWeatherParser.h"
@class TWeatherParser;
@interface TWeatherController : UITableViewController {
UITableView *mTableView;
NSMutableArray *mImage;
NSMutableArray *weatherarray;
TWeatherParser *weather;
}
@property (nonatomic, retain) IBOutlet UITableView *mTableView;
@property (nonatomic, retain) NSMutableArray *weatherarray;
@property (nonatomic, retain) TWeatherParser *weather;
@end
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
TWeatherCell *cell =(TWeatherCell *) [mTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[TWeatherCell alloc] initWithStyle:UITableViewStyleGrouped reuseIdentifier:CellIdentifier] autorelease];
}
TWeatherElement *newobj = [weatherarray objectAtIndex:indexPath.row];
if ([newobj.icon isEqualToString:@"http://\n"])
{
cell.weatherimage.image = [UIImage imageNamed:@"listIcon-H.png"];
}
else {
NSData *imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:newobj.icon]];
cell.weatherimage.image = [UIImage imageWithData:imageData];
[imageData release];
}
cell.reportdate.text = newobj.currentdate;
NSLog(@"this is cell1 value:%@",cell.reportdate.text);
cell.conditionname.text = newobj.conditionname;
NSLog(@"this is cell2 value:%@",cell.conditionname.text);
cell.twotemp.text = [NSString stringWithFormat:@"Temp:%@/%@",newobj.mintemp,newobj.maxtemp];
NSLog(@"this is cell3 value:%@",cell.twotemp.text);
cell.twodirection.text = newobj.wind;
NSLog(@"this is cell4 value:%@",cell.twodirection.text);
cell.humidity.text = newobj.humidity;
NSLog(@"this is cell5 value:%@",cell.humidity.text);
//cell.reportdate.text = newobj.currentdate;
//cell.reportdate.text =@"My journey";
// cell.conditionname.text = @"raji";
// cell.twotemp.text = @"pradeep";
// cell.twodirection.text = @"harish";
// cell.humidity.text =@"23";
// cell.weatherimage.image = [UIImage imageNamed:@"listIcon-H.png"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// Configure the cell...
return cell;
}
If you want to show different values in different cell then you have to use switch case to detect row index :