Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Uitableview -[\uu NSCFString objectAtIndex:]cellForRowAtIndexPath:尝试访问数组objectAtIndex:indexath.row时崩溃_Uitableview_Ios6_Xcode4.5 - Fatal编程技术网

Uitableview -[\uu NSCFString objectAtIndex:]cellForRowAtIndexPath:尝试访问数组objectAtIndex:indexath.row时崩溃

Uitableview -[\uu NSCFString objectAtIndex:]cellForRowAtIndexPath:尝试访问数组objectAtIndex:indexath.row时崩溃,uitableview,ios6,xcode4.5,Uitableview,Ios6,Xcode4.5,我正在从自定义的UITableViewCell(自己的类和nib)将数据加载到UITableView。在我尝试访问某些数组的objectAtIndex:indexath.row之前,它工作得很好 我会先发布我的代码,这样你可能更容易理解我的意思 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndex:]: unrecognized s

我正在从自定义的
UITableViewCell
自己的类和nib)将数据加载到
UITableView
。在我尝试访问某些数组的
objectAtIndex:indexath.row
之前,它工作得很好

我会先发布我的代码,这样你可能更容易理解我的意思

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0xa84a800'
//问题就在这里

//我想在自定义单元格中显示图像并从核心数据获取路径……路径正在获取,但图像未显示在单元格中

-(void)viewWillAppear:(BOOL)animated
{
self.navigationController.navigationBarHidden=YES;
if (managedObjectContext==nil) {
    MFAppDelegate *appDelegate = (MFAppDelegate *)[UIApplication sharedApplication].delegate;
    managedObjectContext = appDelegate.managedObjectContext;

}

NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Last" inManagedObjectContext:managedObjectContext];
[request setEntity:entity];
NSError *error = nil;
NSMutableArray *mutableFetchResults = [[managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
if (mutableFetchResults == nil) {
    // Handle the error.
}

// Set self's events array to the mutable array, then clean up.
[self setFinal:mutableFetchResults];
lastdisarr=[mutableFetchResults valueForKey:@"lastdis"];
lastcalarr=[mutableFetchResults valueForKey:@"lastcal"];
lasttimearr=[mutableFetchResults valueForKey:@"lasttime"];
date=[mutableFetchResults valueForKey:@"lastspeed"];
lasticonarr=[mutableFetchResults valueForKey:@"iconwe"];
NSLog(@"LAst DISTANCE %@",lasticonarr);

}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:   (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
Cell *cell = [table dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
    [[NSBundle mainBundle]loadNibNamed:@"Cell" owner:self options:nil];

    cell=self.custom;
}

// Set up the cell...

cell.distance.text=[lastdisarr objectAtIndex:indexPath.row];
cell.timelab.text=[lasttimearr objectAtIndex:indexPath.row];
cell.callab.text=[lastcalarr objectAtIndex:indexPath.row];
cell.date.text=[date objectAtIndex:indexPath.row];
//cell.wether.image=[lasticonarr objectAtIndex:indexPath.row];


NSMutableArray *ar=[lasticonarr objectAtIndex:indexPath.row];
NSLog(@"%@",ar);
有两种选择:

1:你没有保留你的价值

NSURL *url1 = [NSURL URLWithString:[ar objectAtIndex:indexPath.row]];

NSLog(@"%@",url1);
NSData *data = [NSData dataWithContentsOfFile:[ar description]];


NSLog(@"%@",data);

return cell;

}
2:
[mutableFetchResults valueForKey:@“lastdis”]
是一个
NSString
,而不是预期的
NSArray

lastdisarr  = [[mutableFetchResults valueForKey:@"lastdis"] retain];
lastcalarr  = [[mutableFetchResults valueForKey:@"lastcal"] retain];
lasttimearr = [[mutableFetchResults valueForKey:@"lasttime"] retain];