iphone - How to store a boolean value to an NSArray? -


so i'm storing user settings in plist file , i'm adding data nsarray. approach working me.

my problem i'm adding uiswitch settings , wondering how store on/off state array can access state @ later time?

i'm adding data array this:

[array addobject: myswitch.on]; 

then i'm trying set state this:

[myswitch seton:[array objectatindex:0]]; 

since nsarray takes in (id)s (i.e. objective-c pointers objects), can store objects.

the common way store bool value in object nsnumber class:

[array addobject:[nsnumber numberwithbool:myswitch.on]]; 

to access it, grab nsnumber object , send boolvalue message:

[myswitch seton:[[array objectatindex:0] boolvalue]]; 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -