Reputation: 3111
I have a view that has an "Add" button in its navigation bar. When clicking that button, it slides up a modal view with a form for them to add their item. I would like to inform the calling view controller (the one that had the "Add" button) that the expense has been added so it can do any updating it needs to do. Is there any way to get access to the view controller that initiated the modal view?
Upvotes: 0
Views: 110
Reputation: 2030
if you are in iOS 5.0 you should access this information with presentingViewController
property, and for iOS 2.0 to 4.X parentViewController
property works.
Upvotes: 0
Reputation: 4623
There are two ways that come to mind. Either create a protocol that your modal view uses to inform the calling viewController or by having your modal view post a NSNotification that the calling view controller is observing. In the case of posting the notification, you would send the expense in the userInfo dictionary of the NsNotification object.
Good luck
Upvotes: 2
Reputation: 7976
I believe this property will work parentViewController
Here is a link to the description
Upvotes: 0