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.

NSUserDefaults *savedUID = [NSUserDefaults standardUserDefaults];
[savedUID setObject:UID forKey:@"user_id"];

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.

Need Your Help

How to create Login page in MVC 5 using session ID (database first approach)?

asp.net-mvc asp.net-mvc-5 session-variables session-cookies

I am new to MVC. I want to create login page using session ID so that i can check that ID in each controller and each method in same controller.And is there any requirement of cookie? If yes, then ...