An object from the NSUserDefaults release?

So, I have a username stored in UserDefaults. For some reason, I am experiencing strange behavior.

I have a data controller that sends and retrieves some data from the server based on the username.

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSLog(@"NSUserDefaults dump: %@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);

userID = [prefs stringForKey:@"username"];

This works fine the first few times, but after I do a few random things and come back to try to reload the looks, it will work. It says:

-[CFString retain]: message sent to deallocated instance 0x4b18ff0

This is strange because he stops on the NSLog line. Has anyone seen this before or knows why this might happen?

+3
source share
2 answers

? ,

self.userID = [prefs stringForKey:@"username"];

. , stringForKey, .

+6

stringForKey , , , , , .

, .

- ( , dealloc)

0

Source: https://habr.com/ru/post/1777759/


All Articles