IOS Saving UISegmentedControl Selection in NSUserDefaults

Is there a way to save the value of UISegmentedControl in NSUserDefaults? Should I use it as an integer value in NSUserDefaults?

+3
source share
1 answer

You simply use the selectedSegmentIndex: UISegmentedControl method , and then use the setInteger: forKey: method inside NSUserDefaults . The reason for this (as you seem to hint at your question) is that the selectedSegmentIndex method returns an NSInteger. (His full method signature: @property(nonatomic) NSInteger selectedSegmentIndex)

, ( selectedSegmentIndex).

, ( ), integerSegmentIndex UISegmentedControlNoSegment, , , " ".

+5

Source: https://habr.com/ru/post/1779192/


All Articles