How can you use sender in performSegueWithIdentifier function?
I have programmatically initiated the segue in the following way:
[self performSegueWithIdentifier:@"loginToCategories" sender:object];
I was wondering if the new view controller object would be able to access the "object" that I inserted into the sender.
+3
rmp2150
source
to share
2 answers
If you want the destination view dispatcher to receive the sender in the segment, you will need to send a message to destinationViewController from the method prepareForSegue
.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"MySegue"]) {
MyViewController *destinationViewController = (MyViewController *)segue.destinationViewController;
destinationViewController.sender = sender;
}
}
This question is very similar.
+3
michaelsnowden
source
to share
yes you can access. add this to your loginToCategories
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"yourControllerName"]) {
}
}
+1
rahul_send89
source
to share