Reputation: 5990
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.
Upvotes: 0
Views: 414
Reputation: 8944
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
[[MyDataManager sharedInstance] addPartToBuild:newPart];
[self.navigationController popToRootViewControllerAnimated:YES];
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 sender
is 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).
Upvotes: 1