I use this code to save:
[[NSUserDefaults standardUserDefaults] setValue:@"vruch" forKey:@"nastoikaIP"];
[[NSUserDefaults standardUserDefaults] synchronize];
and this code to load:
NSString* automanual = [[NSUserDefaults standardUserDefaults]
valueForKey:@"nastroikaIP"];
if ([automanual isEqualToString:@"vruch"]) {
autovruch.selectedSegmentIndex = 1;
[self obnovittext];
}
You should not use the method
setValue:(from theNSKeyValueCodingprotocol) butsetObject:(from theNSUserDefaultsclass) to store the string.You can retrieve the string using the method
stringForKey:Finally, note that it is generally better to define constants for the keys you use in
NSUserDefaultsto avoid any mistyping errors, which may be hard to debug when they happen.Edit
It looks like you already did a mistyping error
nastoikaIP!=nastroikaIP. Notice the missing/extrarletter.