in Education by
I'm encountering some problems in integrating segue and protocols while implementing a selection list. In my selection list .h I have: #import @protocol SelectionListViewControllerDelegate @required - (void)rowChosen:(NSInteger)row; @end @interface SelectColor : UITableViewController -(IBAction)saveSelectedColor; @property (nonatomic, strong) id delegate; @end In my selection list .m I have: @implementation SelectColori @synthesize delegate; //this method is called from a button on ui -(IBAction)saveSelectedColore { [self.delegate rowChosen:[lastIndexPath row]]; [self.navigationController popViewControllerAnimated:YES]; } I would like to access to this selection list view by performing a segue from another table view: @implementation TableList ... - (void)selectNewColor { SelectColor *selectController = [[SelectColor alloc] init]; selectController.delegate = (id)self; [self.navigationController pushViewController:selectController animated:YES]; //execute segue programmatically //[self performSegueWithIdentifier: @"SelectColorSegue" sender: self]; } - (void)rowChosen:(NSInteger)row { UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error Title" message:@"Error Text" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [errorAlert show]; } If I navigate to the selection list using: [self.navigationController pushViewController:selectController animated:YES]; the alert is displayed. If I instead use: [self performSegueWithIdentifier: @"SelectColorSegue" sender: self]; no alert is displayed, because, I think, I don't pass to the destination selection list the selectController. Any ideas to solve this issue please? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
When using Segue to pass data to the destinationViewController you need to use the method - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"SelectColorSegue"]) { SelectColor *vc = segue.destinationViewController; vc.delegate = self; } } from the Apple Docs The default implementation of this method does nothing. Subclasses can override it and use it to pass any relevant data to the view controller that is about to be displayed. The segue object contains pointers to both view controllers among other information.

Related questions

0 votes
    I am facing a problem that makes me to waste a lot of time. Each time I insert an element on a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    I am facing a problem that makes me to waste a lot of time. Each time I insert an element on a ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 10, 2022 in Education by JackTerrance
0 votes
    I have an array in one view controller that I want to send to two other view controllers - i am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    I have an array in one view controller that I want to send to two other view controllers - i am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    I have an array in one view controller that I want to send to two other view controllers - i am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    I have a base View Controller with various containers inside it. I use them to control the current step ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    In Ruby on Rails Development (or MVC in general), what quick rule should I follow as to where to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 31, 2022 in Education by JackTerrance
0 votes
    I've managed to read some values into a table view and display them in the Master View of a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    Which of the unit operation is used in Model view controller? (a) Is a Decomposition (b) Part ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    is it possible to call c# methods written in managed code (maybe in a class or a library) from a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    Which design pattern provides a single class which provides simplified methods required by client and delegates call to ... of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
    Why Do We Need Delegates?...
asked Mar 31, 2021 in Education by JackTerrance
0 votes
    What are delegates in C# and the uses of delegates?...
asked Mar 31, 2021 in Technology by JackTerrance
0 votes
    If end to end delay is given by dend-end = N(dproc + dtrans + dprop) is a non congested network. The number of routers between source and destination is? A. N/2 B. N C. N-1 D. 2N...
asked Jan 8, 2023 in Technology by JackTerrance
...