ios - NSUserDefaults setObject:forKey deadlocks? -


today encountered rather confusing problem:

when app starts i'm downloading things , after parsing responses write data nsuserdefaults. working fine until discovered entire ui freezes , wont unfreeze until relaunch app. when hit pause programm execution in debugger get:

stacktrace

the documentation says nsuserdefaults threadsafe , can see no other threads trying access user defaults...

any ideas on how resolve/further debug issue appreciated!

thanks in advance!

code that's causing problem:

this called after receive response webservice:

+ (void)updatewithdata:(nsdata *)data {     nsuserdefaults *userdefaults = [nsuserdefaults standarduserdefaults];      nserror *error;     nsarray *decodeddata;      if (data) {         decodeddata = [nspropertylistserialization propertylistwithdata:data                                                             options:nspropertylistimmutable                                                              format:null                                                               error:&error];     }      if (!error && decodeddata) {         [userdefaults setobject:decodeddata forkey:kuserdatauserdefaultskey];     }     else{         nslog(@"%@", error.localizeddescription);     } } 

updated new code sample:

you should convert decodeddata archived data in order store in nsuserdefaults:

if (!error && decodeddata) {     nsdata *archiveddata = [nskeyedarchiver archiveddatawithrootobject: decodeddata]];     [userdefaults setobject: archiveddata forkey:kuserdatauserdefaultskey]; } 

and retrieve data this:

nsarray *storeddata = [nskeyedunarchiver unarchiveobjectwithdata:[[nsuserdefaults standarduserdefaults] objectforkey:kuserdatauserdefaultskey]]; 

Comments