I want to send data back to my main view when popping
-(IBAction)addPartToBuild:(id)sender{
[self.navigationController popToRootViewControllerAnimated:YES];
}
Could I use sender:data? I tried but I got a “No @interface” error.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You are trying to mess up the MVC (Model View Controller) philosophy, the view controller must be responsible for the UI handling.
You need to build the data-model and the data-controller responsible for the data storage. Then you can add notifications or delegate the data-change events to your root or any other view controller, that would be easy to read and you’ll get all the MVC benefits.
That must be as easy as
And the root view controller should either catch the data-change notification, delegated message or just the UI completely every time it’s shown taking the changed data from your data controller.
Might have misunderstood the question, if you need to know which control has triggered the action, the
id senderis that control reference, e.g. if you link the action to the UIButton the sender will be UIButton reference (you can check it with[sender isKindOfClass:[UIButton calss]]and then get any needed property of the UIButton like you can assign the same action for several buttons and check the button tag to decide what to do, check the Mediator pattern for details).