In a storyboard I have 3 view controllers: firstViewController
, secondViewController
, and controllerA
.
Both firstViewController and secondViewController have a navigation right bar item that presents controllerA using segues in storyboard.
controllerA
has a tableView with custom table cells. In the customTableCell.xib, there is a acceptButton that stores data and pops back to firstViewController. I am able to implement this only if the user go from firstViewController to controllerA by using popViewController.
EDIT: But I am not able to do it if the user gets to ControllerA from secondViewController, because popToViewController would not work. I tried using:
FirstViewController *recordViewController = [[FirstViewController alloc] init];
[self.navigationController pushViewController:recordViewController
animated:YES];
EDIT: I'm getting a crash with this error:
__NSArrayM insertObject:atIndex:]: object cannot be nil'
[SecondViewController recordCardNumber:recordCheckInID:]: unrecognized selector sent to instance 0x17d97250'
There is a delegate relationship between controllerA and firstViewController.
How can I implement this properly?
EDIT: this is the delegate in FirstViewController:
#pragma mark - ControllerADelegate
- (void)recordCardNumber:(NSString *)number recordCheckInID:(NSString *)checkInID
{
self.CardNumbertext.text = number;
NSLog(@"record card# %@", self.CardNumbertext.text);
}
I am passing the data through and popping to firstViewController successfully if I use
[self.delegate recordCardNumber:number recordCheckInID:checkInID ];
[self.navigationController popViewControllerAnimated:YES];
It just crashes if I enter controllerA from SecondViewController because I want to go back to firstViewController once the acceptButton is pressed.