Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
Is this the correct way to write a prep for a segue method, if you have three buttons, each of which segue to different views.

Yes, the segues are named as you see them as string below.

Code:
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"AnswerA"])
    {
        ContentAViewController *cavc = [segue destinationViewController];
        cavc.currentContent = _currentContent;
    } else if ([segue.identifier isEqualToString:@"AnswerB"])
    {
        ContentBViewController *cbvc = [segue destinationViewController];
        cbvc.currentContent = _currentContent;
    } else if ([segue.identifier isEqualToString:@"AnswerC"])
    {
        ContentCViewController *ccvc = [segue destinationViewController];
        ccvc.currentContent = _currentContent;
    }
}
 
Looks about right, given the lack of context.

Are the buttons setup to be the segue source (not sure what the correct term is, but did you ctrl-drag from the button to the new view controller) or are they set to use IBActions where you have to write the code?
 
I ctrl dragged from the buttons yes. Three buttons are each pushing to an individual view controller.

Doesn't work at runtime. If I remove if statements for answerB and answerC segues, at runtime the A button segues to answerA successfully and the others do not. If I run the code as you see it above, all segues fail.
 
Fine now

I was blaming the wrong piece of code.

Turns out the load view method was not annotated as it originally was when the view controller was created for vcAnswerB and vcAnswerC - and the load view method was not calling [super load view];

Thanks for looking at this anyway.

Regards
Rob
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.