views:

41

answers:

2

I have a loging screen with a UISwitch for letting the user choose "remember me" so I can store his/her credentials on the key chain if desired.

This will only happen if the user has chosen "remember me" AND the server accepts the username/password. However, when the server replies, I have a hard time referring to the state of the UISwitch. The value of myUISwitch.on is, to my surprise (null).

NSLog (@"(Successful login. Value of UISwitch rememberMe: %@)", rememberMe.on);

Must I store this information in a temporary boolean?

A: 

Is the view still not released by the time you refer to the switch? Is the UISwitch already released by the runtime? When did you attempt to read its state? Is the control still on the screen by the time you read its state?

Evadne Wu
A: 

If it is null, it is not the on property but the rememberMe variable, which is not set. Wire it up correctly in Interface Builder or in code.

Also, make sure to access UIKit always from the main thread, i.e. use performSelectorOnMainThread:enter code here.

Eiko