Given a storyboard-based application, how can any one view controller invoke the methods of any other (to gain access to its encapsulated information) without executing the prepareForSegue method (which only passes the destination vc's reference via the segue argument)? I understand that information can be passed from a parent vc to a child vc but I need a more generic approach for any vc to pass information to any other at any point in time.
Put another way, while in vc A, I would like to invoke a method in vc B (that is not named in any segue from A), but don't understand how to get a reference to B from A. Creating a new segue to it would create a new vc; not what I want to do.
I would think there is some way via the storyboard or its associated named segue functions to track down a reference to any vc from any other but have struggled to find a way to do so. In the deeply embedded world I normally live in, I would simply create a singleton class so it could be instantiated from anywhere but that seems inappropriate (if even possible) here for the case of a view controller.
Cualquier ayuda sería muy apreciada.
preguntado el 01 de febrero de 12 a las 03:02
I would suggest you not try to do this via storyboard segue functions. Try using NSNotifications. You'll have to code these yourself (i.e. not in Storyboard), but they will allow you to broadcast a "request" that VC-B invoke a method, based on what information you pass it in the notification. VC-B has to be listening for it (observing), but this is a very nice way of de-coupling your classes, but still communicating in an arbitrary way.