Reputation: 3007
I have added a UITableViewController
with static cells. I have a bar button 'save', but when I click on the button, the prepareForSegue
method is not called at all.
Here is my code:
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"AddCustomer"]) {
UINavigationController *navigationController = segue.destinationViewController;
AddCustomersViewController *addCustomersViewController = [[navigationController viewControllers] objectAtIndex:0];
addCustomersViewController.delegate = self;
}
}
and here is my delegates method
-(void) customerDidSave:(AddCustomersViewController *)controller newCostomer:(Customers *)customer
{
[self dismissViewControllerAnimated:YES completion:nil];
[self.customers addObject:customer];
[self.tableView reloadData];
}
I don't know what is the problem. Any ideas?
Upvotes: 0
Views: 1181
Reputation: 1528
Replace with;
if ([segue.identifier isEqualToString:@"AddCustomer"]) {
[[segue destinationViewController] setDelegate:self];
}
This is unnecessary, and probably what is causing the problems - [[navigationController viewControllers] objectAtIndex:0]
Upvotes: 0
Reputation: 3805
Yeah, your segue is not connected to the view controller class in IB, or the clas name of the view controller is not set to your view controller class
Upvotes: 1