我正在使用核心數據,我是obj-c的新手。我試圖將我的核心數據中的「緯度」和「經度」傳遞給mapViewController
。我無法將數據uitableviewcell傳遞到destinationviewcontroller
代碼:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"ShowMap"]) {
HaritaVC *destViewController = segue.destinationViewController;
NSIndexPath *path = [self.myTableView indexPathForSelectedRow];
NSString *lattoPass = [NSString stringWithString:[[self.fetchedRecordsArray objectAtIndex:path.row]objectForKey:@"lat"]];
NSString *lontoPass = [NSString stringWithString:[[self.fetchedRecordsArray objectAtIndex:path.row]objectForKey:@"lon"]];
destViewController.latt = [[NSString alloc] initWithFormat:@"%@",lattoPass];
destViewController.lonn = [[NSString alloc] initWithFormat:@"%@",lontoPass];
}
}
和我 「的tableview」 代碼:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"MainCell";
CellDetail *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
Notlar * notlar = [self.fetchedRecordsArray objectAtIndex:indexPath.row];
cell.titleLabel.text = [NSString stringWithFormat:@"%@ %@, %@ ",notlar.bilgi,notlar.notlar,notlar.tarih];
return cell;
}
當我點擊tableViewCell
,我得到這個錯誤:
'NSInvalidArgumentException', reason: '-[Notlar objectForKey:]: unrecognized selector sent to instance 0x1aa56b60'
什麼是'Notlar'? – Larme
向我們展示您的'didSelectRowAtIndexpath' – Templar
它看起來像您返回的值fetchedRecordArray不是您的Notlar對象的實例。遍歷代碼,並可能打印出返回的對象,以瞭解它是什麼。可能是零值嗎? –