I´m doing some stuff in the background (Networking, Core Data, ...).
There is also the following line called in some methods:
[[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"SyncDate"];
Everytime, except the first time, when this line is called, it will crash. but only in a background thread.
Here is my stack trace:
Thread : Crashed: com.apple.root.background-qos
0 libobjc.A.dylib 0x0000000199b0dbd0 objc_msgSend + 16
1 Foundation 0x0000000185ea1eb4 -[NSObject(NSKeyValueObserverNotification) willChangeValueForKey:] + 324
2 CoreFoundation 0x0000000185090994 _CFPreferencesSetValueWithContainer + 168
3 Foundation 0x0000000185eb9138 -[NSUserDefaults(NSUserDefaults) setObject:forKey:] + 56
4 AIR 0x00000001000ebd70 -[ServerSyncAgent syncUnsyncedEntities]
5 AIR 0x0000000100145568 __37-[StreamListener stream:handleEvent:]_block_invoke88
6 libdispatch.dylib 0x000000019a2e97b0 _dispatch_call_block_and_release + 24
7 libdispatch.dylib 0x000000019a2e9770 _dispatch_client_callout + 16
8 libdispatch.dylib 0x000000019a2f7bb0 _dispatch_root_queue_drain + 2140
9 libdispatch.dylib 0x000000019a2f734c _dispatch_worker_thread3 + 112
10 libsystem_pthread.dylib 0x000000019a4fd478 _pthread_wqthread + 1092
I do not observe NSUserDefaults with KVO in any place and NSUserDefaults is thread safe.
Any ideas?