Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 0xa84a800'
UITableView
カスタムUITableViewCell
(独自のクラスとペン先)から、にデータをロードしています。objectAtIndex:indexPath.row
いくつかの配列にアクセスしようとするまで、それはうまく機能します。
最初にコードを投稿します。そうすれば、私の意味が理解しやすくなります。
-(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);
//問題はここにあります
//カスタムセルに画像を表示し、コアデータからパスを取得したい....パスは取得されているが、セルに画像が表示されない
NSURL *url1 = [NSURL URLWithString:[ar objectAtIndex:indexPath.row]];
NSLog(@"%@",url1);
NSData *data = [NSData dataWithContentsOfFile:[ar description]];
NSLog(@"%@",data);
return cell;
}