Tuesday, 20 August 2013

NSUserDefaults not being saved in simulator ,even though I use synchronize

NSUserDefaults not being saved in simulator ,even though I use synchronize

I add a dictionary to NSUserDefaults and call 'synchronize' method,but it
doesn't save user defaults when I terminate my app by stopping it in
Xcode.
NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
NSDictionary *dict=[[NSDictionary alloc]
initWithObjectsAndKeys:startTime,kStartTime,
endTime,kEndTime,
nil];
[defaults registerDefaults:dict];
[defaults synchronize];
And
NSString *startTimeValue=[defaults stringForKey:kStartTime];
the startTimeValue is still nil When I reopen my app in simulator

No comments:

Post a Comment