So I’m storing user settings in a plist file and to do that I’m adding data to an NSArray. This approach is working for me.
My problem is that now I’m adding a UISwitch to the settings and I was wondering how to store their ON/OFF state to the array so that I can access that state at a later time?
I’m adding data to the array like this:
[array addObject: mySwitch.on];
Then I’m trying to set the state like this:
[mySwitch setOn:[array objectAtIndex:0]];
Since
NSArrayonly takes in(id)s (i.e. Objective-C pointers to objects), you can only store objects.The common way to store a
BOOLvalue in an object is with theNSNumberclass:To access it, grab that
NSNumberobject and send it aboolValuemessage: