I almost despair because my settings doesn’t save properly.
I save a setting in a UITableView when a user select a cell:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
checkedCell = indexPath;
NSUInteger row1 = [indexPath row];
NSString *TD = [listData objectAtIndex:row1];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:TD forKey:@"TestData"];
[defaults synchronize];
NSLog(@"Save");
[tableView reloadData];
}
In an other ViewController i load the Data and make a if-else statement:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *TD = [defaults objectForKey:@"TestData"];
NSLog(@"%@",TD);
if (TD == @"0") {
NSString *NTD = @"TRUE";
}
else {
NSString *NTD = @"FALSE";
}
}
I see that the NSLog is 0 but NTD is FALSE.
Make if condition like this
if ([TD isEqualToString:@”0″]) {
Surely this will helpful