0

I'm making a preference bundle where the specifiers are loaded from a .plist file. Some of the specifiers are UISwitches. How can I have a function called when the value of one of the UISwitches is changed?

Yuyutsu
  • 2,509
  • 22
  • 38
KyleCool1
  • 13
  • 3
  • This might help you : http://stackoverflow.com/questions/23986150/uiswitch-doesnt-change-state – Yuyutsu Dec 26 '14 at 18:50
  • go through this : http://stackoverflow.com/questions/11847059/objective-c-writing-uiswitch-state-in-a-plist-for-a-key?answertab=active#tab-top – Yuyutsu Dec 26 '14 at 18:58

2 Answers2

0

To detect when changes to a preference value occur, apps can also register for the notification NSUserDefaultsDidChangeNotification. The shared NSUserDefaults object sends this notification to your app whenever it detects a change to a preference located in one of the persistent domains. You can use this notification to respond to changes that might impact your user interface. For example, you could use it to detect changes to the user’s preferred language and update your app content appropriately.

Register for this notification. When you receive it, check whether the switch has changed. Unfortunately, the notification doesn't tell you what change triggered it.

Aaron Brager
  • 65,323
  • 19
  • 161
  • 287
0

UISwitches are UIControls so you can receive actions from them just like UIButtons.

Jean-Baptiste Yunès
  • 34,548
  • 4
  • 48
  • 69