この問題を解決するために最善を尽くしましたが、次のエラーが引き続き発生します。
-[__NSCFConstantString ling]: 認識されないセレクターがインスタンス 0x12f80b0 に送信されました
私がやろうとしているのは、アラートビューからのテキストを使用してコアデータとテーブルビューに行を追加することです。そのため、アラートビューを起動し、ユーザーが新しい言語の名前を入力すると、アラートビューのテキストが保存されますコア データに追加され、ユーザーが [保存] をクリックするとテーブル ビューに追加されます。
テーブル ビューでは、これは関連するコードです。
- (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;
}
そしてアラートビューでは、これは「保存」ボタンがクリックされたときのコードです:
- (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])
{
}
}
}
誰かが私が間違っていることを教えてもらえますか??