I am getting an error when changing the datasource of my TableView from an NSArray with objects(the example I found) to an NSMutableArray with the actual values I need to populate my table view with.
error:
lat is: 33, long is: -74, 2012-03-06 12:27:58.380 x[606:fb03] -[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x6b64280 2012-03-06 12:27:58.381 x[606:fb03] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x6b64280'
the original way I was setting self.measurement and self.subinfo is commented out.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MeasurementCell"];
switch (indexPath.section)
{
case kMeasurement:
cell.textLabel.text=[self.measurements objectAtIndex:indexPath.row];
cell.detailTextLabel.text=[self.subinfo objectAtIndex:indexPath.row];
break;
default:
cell.textLabel.text=@"Unkown";
}
return cell;
}
- (void)viewDidLoad
{
appdelegate = [[AppDelegate alloc]init];
//get lat
NSArray* fmArray = [appdelegate fetchEvents:@"Field_Measurement"];
NSMutableArray* latBindArray = [[NSMutableArray alloc]init];
NSMutableArray* longBindArray = [[NSMutableArray alloc]init];
for (Field_Measurement *fm in fmArray)
{
[latBindArray addObject:fm.latitude];
NSLog(@"lat is: %@", fm.latitude);
}
for (Field_Measurement *fm in fmArray)
{
[longBindArray addObject:fm.longitude];
NSLog(@"long is: %@", fm.longitude);
}
self.measurements = latBindArray;//[[NSArray alloc]initWithObjects:@"03/05/2012 @ 15:12", @"03/05/2012 @ 11:11", nil];
self.subinfo = latBindArray;//[[NSArray alloc]initWithObjects:@"Beta: 0.0234",@"Alpha: 3.977", nil];
[super viewDidLoad];
}
this is my first attempt at a table view(and new to objective-c all together) so any ideas of how to populate the table view from a NSMutableArray would be helpful. I have a sqlite database that I am pulling these records from if that helps.
thanks