Simple question about how to pass information in my iOS application.
The appDelegate has a variable myVar.
I have a UIViewController with a View with a switcher. When the switcher switches, I need to set another value to myVar.
Since UIViewController is not supposed to know the interface of appDelegate, how can I notify it about the switch and update its variable?
NB. If you are going to answer "just send a message", please let me know how to implement it as well, since it is not clear.
thanks
Well, you can send a message. You'll get a warning about it, but it will work.
After finding out you don't need app-wide state, NSNotification
s are a good way to go here.
http://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html#//apple_ref/doc/uid/TP40009542-CH5-SW1
Can you do similar to keyboard notifications?
Idea is to implement custom Switch which sends notifications to all registered listeners; register what ever object you think should receive notifications.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.