Make the following change:
NSString getPhone = [[NSUserDefaults standardUserDefaults] objectForKey:@"phoneNumber"];
NSLog(@"%@",getPhone);
hm, strange issue. you can print out getPhone directly after set user defaults to understand if some other part of code does not modify it. [[NSUserDefaults standardUserDefaults] setObject:myPhoneString forKey:@"phoneNumber"];
So try this:
NSLog(@"%@", myPhoneString); // check current value
[[NSUserDefaults standardUserDefaults] setObject:myPhoneString forKey:@"phoneNumber"];
NSLog(@"%@", [[NSUserDefaults standardUserDefaults] objectForKey:@"phoneNumber"]) // check value after set it.
values should be the same, but also you will need to print this value in another place to test if some other code have not modified it. (I mean in place where you print it NSLog(@"%@",getPhone);
)
Alos be sure that you set NSString to the NSUserDefault instead of data because as I see in your example you set NSString and output NSString as well so you don't need NSData in this your case.