0

I have a UIViewController that has a button which in turn launches another UIViewController in the form of a Popover.

Now on the popover view controller I can perform an action (Add User). How can I notify the parent view controller when dismissing the popover view controller that an action has been performed i.e user added?

Thanks

Antony Raphel
  • 2,036
  • 2
  • 25
  • 45
ORStudios
  • 3,157
  • 9
  • 41
  • 69
  • 1
    you can use notificationcenter..i mean use observer – Brijesh Shiroya Mar 08 '17 at 11:54
  • 2
    use delegate pattern. – Sunny Mar 08 '17 at 11:55
  • 1
    Use this link http://stackoverflow.com/a/19343715/6438500 – Sunny Mar 08 '17 at 11:58
  • Thanks guys, I have gone with the notification approach because it's quite a simple approach and in theory it just is a notification. – ORStudios Mar 08 '17 at 12:29
  • If you have two instance of the same view controller opening the popover (common in a tab-based app), when the notification fires, both instance will receive the notification and both instance will close the popover even though you might just want to close it in one of them. Delegate pattern is the recommended solution. – Zhang Mar 08 '17 at 14:01
  • Indeed. I generally prefer to avoid Notifications unless it is about UI changes which do not have any other impact on App's functionality. Moreover, in case of a bug, Notifications make it difficult to debug the issue which is why I prefer delegate pattern – NSNoob Mar 08 '17 at 15:58

0 Answers0