例外ブレークポイントを設定しましたがunrecognized selector sent to instance
、インスタンスが UITableViewCell 自体であるというエラーが発生していました。アプリは CoreData を使用し、UITextfield の編集が終了したら、テキストを NSManagedObject に保存したいと考えています。
textFieldDidEndEditing
私のTableViewController内のメソッドは次のとおりです。
- (void)textFieldDidEndEditing:(UITextField *)textField {
MCSwipeTableViewCell *cell = (MCSwipeTableViewCell *) textField.superview.superview;
TehdaItem *item = [self.fetchedResultsController objectAtIndexPath:[self.tableView indexPathForCell:cell]];
item.itemTitle = cell.itemLabel.text; //The exception gets thrown on this line
// itemLabel is a UITextField and itemTitle is a string attribute of TehdaItem the NSManagedObject
NSError *error;
[item.managedObjectContext save:&error];
if (![self.fetchedResultsController performFetch:&error]) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
}
これ<UITextFieldDelegate>
は私のTableViewControllerとして設定され、UITextFieldのデリゲートとして設定しました。ここで何が問題なのか本当にわかりません。
編集:最後のsuperview
呼び出しを削除するとMCSwipeTableViewCell *cell = (MCSwipeTableViewCell *) textField.superview.superview;
、問題が解決しました。