NSUserDefaults not setting Toggle Switches in Table!?
Hi,
My root.plist has about 6 PSToggleSwitchSpecifiers. I am trying to access all of them through my application and through a UITableView controller.
I check in viewDidLoad that the UserDefaults are in fact their default values (a couple 1's and a couple 0's). In the cellForRowAtIndexPath method, I use an existing cell or create a cell with a UISwitch in the accessory view. I also give the switch a tag #.
Then, i set the UISwitch (after setting the label text):
UISwitch *switchView = (UISwitch *)[cell viewWithTag:kSwitchTag];
[switchView setOn: [[[NSUserDefaults standardUserDefaults] stringForKey:rowString]intValue] animated:NO];
SO THE QUESTION IS:
The toggle switches all show up OFF when the view loads. However, if I "throw" the screen down in an attempt to scroll (there are only 6 rows so there isn't anywhere to scroll really), the switches set to ON appropriately. How can I get these switches to load properly when the view appears?!!
One more thing, I put [self.tableView reloadData], [self.tableView setNeedsLayout], and [self.tableView setNeedsDisplay] in both viewDidAppear and viewWillAppear methods, and that doesn't work.
Woe is me! Thanks to whoever can help! -Morgan
|