Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top