In my scenario I have 2 view controllers, one tied to the main view and one that is connected to the first one as a subview.
Now let’s say that my App Delegate class wants to pass a string to the subview controller. What is the best practice to achieve this? If I wanted to pass it to the 1st controller i could just say something like
[self.firstController getStringInCustomFunction:[NSString stringWithFormat:@'200%d', 9]];
Also keep in mind that this call might have to be asynchronous.
Coming from ActionScript, normally I would just add and event listener and move my variables though events. What’s the equivalent in objective-c?
Coming from ActionScript, normally I would just add and event listener and move my variables though events. What’s the equivalent in objective-c?
Take a look at
NSNotificationCenter.Specifically,
postNotificationName:object:userInfo, wherein you create anNSNotificationthat includes anNSDictionaryof objects you pass insideuserInfo.On the other end, you have another object that is registered to ‘hear’ an NSNotification of a specific name. That other object calls whatever method is specified in the registration. You might unpackage the
userInfodictionary in this method, to retrieve the object of interest.