Why won't my NSUserDefaults load?
So I have an iphone app that presents a modal view when it starts if the user has not registered. Once they register, it saves a user ID into NSUserDefaults. When the app starts at a later time, it needs to load this user id in the appdelegate file.
//Registration.m NSUserDefaults *savedUID = [NSUserDefaults standardUserDefaults]; [savedUID setObject:UID forKey:@"user_id"]; //AuctionTracAppDelegate.m NSUserDefaults *savedID = [NSUserDefaults standardUserDefaults]; NSString *uidString = [savedID stringForKey:@"user_id"];
My problem is that when I try to load this value at a separate execution, the object I saved is always null. I know for a fact that it is saving the string object correctly. Also, this weird behavior JUST surfaced. This exact code was working earlier, then after working on a totally unrelated file, this code fails. I'm clueless as to what happened. Any hints?
I believe that you need to call the synchronize method.