I'm currently setting up the "Settings/preferences" side of my first app in iOS. i currently have NSUserdefaults setup so that the app remembers the users preferences. I have 2 questions:
Firstly, once a particular cell has been selected it is checkmarked and saved as a default(works), but when i move back to the main setting tableview, i have a label on the cell that it links with that needs to update but doesn't until i move back further to main page, then load settings again. a way to refresh the setting view? Main page(viewcontroller) also has a label that i need to update which doesn't either.
Secondly, when going into say the "measurement tableview with "kph" or "mph". How can i make the cell checkmarked indicating its the current selection from defaults? The current code for one of the tableview preferences is bellow:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Uncheck the previous checked row
if(self.checkedIndexPath)
{
UITableViewCell* uncheckCell = [tableView cellForRowAtIndexPath:self.checkedIndexPath];
uncheckCell.accessoryType = UITableViewCellAccessoryNone;
}
UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
self.checkedIndexPath = indexPath;
NSLog(@"cell.textLabel.text = %@",cell.textLabel.text);
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:cell.textLabel.text forKey:@"windSpeed"];
[defaults synchronize];
}