当我的TableView的数据源从具有对象的NSArray(我发现的例子)更改为NSMutableArray与我需要填充我的表视图的实际值时,我得到一个错误。设置从NSMutableArray的UITableView错误
错误:
LAT是:33, 长为:-74, 2012-03-06 12:27:58.380 X [606:FB03] - [__ NSCFNumber isEqualToString:]:无法识别的选择发送到实例0x6b64280 2012-03-06 12:27:58.381 x [606:fb03] *由于未捕获的异常'NSInvalidArgumentException',原因:' - [__ NSCFNumber isEqualToString:]:无法识别的选择器发送到实例0x6b64280'
我设置self.measurement和self.subinfo的原始方式被注释掉了。
- (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:
[email protected]"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];
}
这是我在一个表视图第一次尝试(和新的Objective-C一起),所以如何填充从NSMutableArray的表视图将是有益的任何想法。如果有帮助,我有一个sqlite数据库,我拉这些记录。
感谢
完蛋了,我想这是一个铸造的问题,但由于某些原因的.text没有点击。感谢亚伦 – BamBamBeano 2012-03-06 18:07:16