简体   繁体   English

NSManagedObject的编译器警告

[英]Compiler warning at NSManagedObject

Why do I receive following compiler warning: 为什么收到以下编译器警告:

Incompatible pointer types sending 'NSManagedObject *' to parameter of type 'ToDoItem *'

at the last line of this method?: 在此方法的最后一行?:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSManagedObject *object = [[self fetchedResultsController] objectAtIndexPath:indexPath];
    self.detailViewController.editToDoItem = object;
}

ToDoItem is a NSManagedObject subclass. ToDoItem是一个NSManagedObject子类。

self.detailViewController.editToDoItem expects a ToDoItem object, so you cannot pass an object of the NSManagedObject superclass : self.detailViewController.editToDoItem需要一个ToDoItem对象,因此您不能传递NSManagedObject 超类的对象:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    ToDoItem *object = [[self fetchedResultsController] objectAtIndexPath:indexPath];
    self.detailViewController.editToDoItem = object;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM