I have 2 entities: Event and User.
Event has many users. I have a tableview that lists all the events and when i click on one row, i get this row’s managed object. and i set the destination view controler’s managed object to this. Everything is working, but i can’t addUsersObject. There is no code hint.
the code like this:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
Event *object = [self.fetchedResultsController objectAtIndexPath:indexPath];
EventsViewController *eventsVC = [[EventsViewController alloc] init];
eventsVC.event = object;
[self.navigationController pushViewController:eventsVC animated:YES];
}
Event.h
@interface Event (CoreDataGeneratedAccessors)
- (void)addUsersObject:(User *)value;
- (void)removeUsersObject:(User *)value;
- (void)addUsers:(NSSet *)values;
- (void)removeUsers:(NSSet *)values;
In the destination view controller, when i do [self.event add] , i can’t get addUsersObject. I thinks its because i didn’t alloc and init Event. but if i do this, i would create a new event object. i need the object from the select row.
How do you declare the
eventproperty inEventsViewController.hYou need to declare it as an
Eventclass property:In order to use the
Eventclass you’ll need to import the header file intoEventsViewController.hIf your code-completion is still not working, you may need to delete the derived data for the project – Close your project, then go to the Organizer, select your project, and click the Delete… button next to Derived Data. Then reopen the project – after the indexing finishes you should regain your code completion.