I’m new to Objective-C and XCode and I’ve encountered such a problem.
How do you properly save the value to NSUserDefaults.
I have value in
[_textFields objectAtIndex:2]).text
And trying to do this
[[[NSUserDefaults standardUserDefaults] setValue:((UITextField *)[_textFields objectAtIndex:2]).text)) forKey:@"Phone"];
[[NSUserDefaults standardUserDefaults] synchronize];
How do you do it properly?
Use
setObject:forKey:instead ofsetValue:forKey:Update:
You code will work if you really have that text field in the array. Here is the step by step broken down code to make it more clear: