When using:
[[NSUserDefaults alloc] initWithSuiteName:@"TestSuiteName"];
It sometimes cause crash, the crash detail is:
Thread 4 name: com.apple.root.user-interactive-qos
Thread 4 Crashed:
0 CoreFoundation 0x1963f9b10 __CFCheckCFInfoPACSignature + 4
1 CoreFoundation 0x19643ed64 CFBundleGetInfoDictionary + 24
2 CoreFoundation 0x19643ed1c CFBundleGetIdentifier + 16
3 Foundation 0x195053740 -[NSUserDefaults(NSUserDefaults) _initWithSuiteName:container:] + 84
4 UIKitCore 0x198e26ef0 ___UIKitUserDefaults_block_invoke + 40
5 libdispatch.dylib 0x19e0ee0d0 _dispatch_client_callout + 20
6 libdispatch.dylib 0x19e0ef918 _dispatch_once_callout + 32
7 UIKitCore 0x198e9de28 _UIKitUserDefaults + 80
8 UIKitCore 0x198f58a7c ___UIKitPreferencesOnce_block_invoke + 20
9 libdispatch.dylib 0x19e0ee0d0 _dispatch_client_callout + 20
10 libdispatch.dylib 0x19e0ef918 _dispatch_once_callout + 32
11 UIKitCore 0x198f56c8c _UIKitPreferencesOnce + 80
12 UIKitCore 0x198f563b8 ___UIApplicationMainPreparations_block_invoke + 20
13 libdispatch.dylib 0x19e0ec370 _dispatch_call_block_and_release + 32
14 libdispatch.dylib 0x19e0ee0d0 _dispatch_client_callout + 20
15 libdispatch.dylib 0x19e0fff60 _dispatch_root_queue_drain + 860
16 libdispatch.dylib 0x19e100590 _dispatch_worker_thread2 + 156
17 libsystem_pthread.dylib 0x21d7dfc40 _pthread_wqthread + 228
18 libsystem_pthread.dylib 0x21d7dc488 start_wqthread + 8
and for more detail crash info can see the attachment image . And Refer to the API's description:
/// -initWithSuiteName: initializes an instance of NSUserDefaults that searches the shared preferences search list for the domain 'suitename'. For example, using the identifier of an application group will cause the receiver to search the preferences for that group. Passing the current application's bundle identifier, NSGlobalDomain, or the corresponding CFPreferences constants is an error. Passing nil will search the default search list.
- (nullable instancetype)initWithSuiteName:(nullable NSString *)suitename API_AVAILABLE(macos(10.9), ios(7.0), watchos(2.0), tvos(9.0)) NS_DESIGNATED_INITIALIZER;
It seems using a constants string is a wrong way. Does any one know what to root cause?
It sometimes cause crash, the crash detail is:
The fact that:
-
This happens infrequently, and
-
The crash is deep within system code
suggests that this is a memory corruption issue. I recommend that you run your app with the standard memory debugging tools to see if you can make it happen more frequently. If you can, that’ll make it easier to debug.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"