简体   繁体   中英

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.

self.detailViewController.editToDoItem expects a ToDoItem object, so you cannot pass an object of the NSManagedObject superclass :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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