0
我尽我所能来解决这个问题,但我不断收到以下错误:与iOS的iPhone应用程序的数据核心未解MATTER
- [__ NSCFConstantString灵]:无法识别的选择发送到实例0x12f80b0
我我试图做的是将行添加到核心数据和表格视图与alertview中的文本,因此启动一个alertview并且用户把一个新语言的名称,然后在alertview中的文本将被保存到核心数据并在用户单击保存时添加到表格视图。
在表视图,这是相关代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if(cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Languages *languagesDict = (Languages *)[languagesArray objectAtIndex:indexPath.row];
cell.textLabel.text = [languagesDict ling];
return cell;
}
而在alertview这是当“保存”按钮被点击代码:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1)
{
NSString *tempText = [alertView textFieldAtIndex:0].text;
if(!languagesArray)
{
languagesArray = [[NSMutableArray alloc]init];
}
[languagesArray insertObject:tempText atIndex:0];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
Languages *languagesDict = [NSEntityDescription insertNewObjectForEntityForName:@"Languages" inManagedObjectContext:_managedObjectContext];
[languagesDict setLing:tempText];
NSError *error = nil;
if (![_managedObjectContext save:&error])
{
}
}
}
有人能告诉我是什么是我做的错事?