objective-c – Zeroing the NSManagedObject subclass


Some action from clicking a cell in the tableView produces a new object and navigates to another viewController :

    User *user = [self.fetchedResultsController objectAtIndexPath:indexPath];
    [self.delegate setSupervisorGUID:user.server_id supervisorTitle:user.name];
    [self.navigationController popViewControllerAnimated:YES];

on the same viewController there is a button that should also change the viewController but without setting a value (zeroing the object as an option to cancel the action):

    [self.delegate setSupervisorGUID:[NSNull null] supervisorTitle:user.name];
    [self.navigationController popViewControllerAnimated:YES];

This option solves the problem, but, of course, is incorrect from the point of view of logic and of course gives a warning . How to solve the problem correctly?


As it turned out, there is no need to create a related object with empty fields (or to zero it), since in fact the undo operation did not imply the need for an object. An important factor was that the supervisor information was local to only one controller and not globally to the project as @Stanislaw Pankevich noted .

Scroll to Top