State recovery failure reports (decodeObject?)

I get these crash reports from Xcode (I pasted one from the bottom) and I cannot reproduce the error or find out what the problem is.

From backtrace, I think it could be related to the material decodeObject... I had some problems with the new features decodeBooland decodeDoubletherefore I did an NSCoder extension:

func safeDecodeDouble(key: String) -> Double? {
    if self.containsValue(forKey: key) {
        if let value = self.decodeObject(forKey: key) as? Double {
            return value
        }
        return self.decodeDouble(forKey: key)
    }
    return nil
}

func safeDecodeBool(key: String) -> Bool? {
    if self.containsValue(forKey: key) {
        if let value = self.decodeObject(forKey: key) as? Bool {
            return value
        }
        return self.decodeBool(forKey: key)
    }
    return nil
}

func safeDecodeDate(key: String) -> Date? {
    if self.containsValue(forKey: key) {
        if let value = self.decodeObject(forKey: key) as? Date {
            return value
        }
    }
    return nil
}

func safeDecodeString(key: String) -> String? {
    if self.containsValue(forKey: key) {
        if let value = self.decodeObject(forKey: key) as? String {
            return value
        }
    }
    return nil
}

Now I only use functions safeDecodein my code, but I still get the same crash reports.

The third paragraph in backtrace says [UIStoryboard storyboardWithName:bundle:], but I don't know what this could do with anything. In addition, each crash report has something about state recovery and decodeObject, therefore, I think the problem is not creating an instance of the storyboard as such.

, , , .

, ?


Last Exception Backtrace:
0   CoreFoundation                  0x18a146fd8 __exceptionPreprocess + 124 (NSException.m:165)
1   libobjc.A.dylib                 0x188ba8538 objc_exception_throw + 56 (objc-exception.mm:521)
2   UIKit                           0x190a36850 +[UIStoryboard storyboardWithName:bundle:] + 776 (UIStoryboard.m:99)
3   UIKit                           0x190bfacfc -[_UIStoryboardProxy initWithCoder:] + 192 (UIStateRestorationSupport.m:324)
4   Foundation                      0x18ab96420 _decodeObjectBinary + 2076 (NSKeyedArchiver.m:2304)
5   Foundation                      0x18ab95b58 _decodeObject + 308 (NSKeyedArchiver.m:2467)
6   UIKit                           0x1903e62ec -[UIStateRestorationKeyedUnarchiver decodeObjectForKey:] + 88 (UIStateRestorationSupport.m:454)
7   UIKit                           0x1903e5ba8 -[UIApplication(StateRestoration) _restoreApplicationPreservationStateWithSessionIdentifier:beginHandler:completionHandler:] + 4772 (UIApplication.m:13551)
8   UIKit                           0x1902e76b4 -[UIApplication(StateRestoration) _doRestorationIfNecessary] + 244 (UIApplication.m:13979)
9   UIKit                           0x1902e7288 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 296 (UIApplication.m:1792)
10  UIKit                           0x1904f3800 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3452 (UIApplication.m:2129)
11  UIKit                           0x1904f92a8 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1684 (UIApplication.m:3625)
12  UIKit                           0x19050dde0 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke.3151 + 48 (UIApplication.m:10365)
13  UIKit                           0x1904f653c -[UIApplication workspaceDidEndTransaction:] + 168 (UIApplication.m:2990)
14  FrontBoardServices              0x18bcef884 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36 (FBSSerialQueue.m:158)
15  FrontBoardServices              0x18bcef6f0 -[FBSSerialQueue _performNext] + 176 (FBSSerialQueue.m:177)
16  FrontBoardServices              0x18bcefaa0 -[FBSSerialQueue _performNextFromRunLoopSource] + 56 (FBSSerialQueue.m:206)
17  CoreFoundation                  0x18a0f5424 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1943)
18  CoreFoundation                  0x18a0f4d94 __CFRunLoopDoSources0 + 540 (CFRunLoop.c:1989)
19  CoreFoundation                  0x18a0f29a0 __CFRunLoopRun + 744 (CFRunLoop.c:2821)
20  CoreFoundation                  0x18a022d94 CFRunLoopRunSpecific + 424 (CFRunLoop.c:3113)
21  UIKit                           0x1902e045c -[UIApplication _run] + 652 (UIApplication.m:2658)
22  UIKit                           0x1902db130 UIApplicationMain + 208 (UIApplication.m:4089)
23  Leio                            0x1000b6ecc main + 120 (BookInfoTableViewController.swift:19)
24  libdyld.dylib                   0x18903159c start + 4

: , , . .:/

0   CoreFoundation                  0x18385adb0 __exceptionPreprocess + 124 (NSException.m:162)
1   libobjc.A.dylib                 0x182ebff80 objc_exception_throw + 56 (objc-exception.mm:531)
2   Foundation                      0x1841d4704 -[NSCoder(Exceptions) __failWithException:] + 132 (NSCoder.m:544)
3   Foundation                      0x1841d48bc -[NSCoder(Exceptions) __failWithExceptionName:errorCode:format:] + 440 (NSCoder.m:580)
4   Foundation                      0x1841a33b8 _decodeObjectBinary + 2996 (NSKeyedArchiver.m:2173)
5   Foundation                      0x1841a274c _decodeObject + 304 (NSKeyedArchiver.m:2313)
6   UIKit                           0x188b3e20c -[UIStateRestorationKeyedUnarchiver decodeObjectForKey:] + 88 (UIStateRestorationSupport.m:454)
7   UIKit                           0x188b3daf8 -[UIApplication(StateRestoration) _restoreApplicationPreservationStateWithSessionIdentifier:beginHandler:completionHandler:] + 4908 (UIApplication.m:15043)
8   UIKit                           0x188a32d44 -[UIApplication(StateRestoration) _doRestorationIfNecessary] + 244 (UIApplication.m:15471)
9   UIKit                           0x188a32964 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 308 (UIApplication.m:1860)
10  UIKit                           0x188c62184 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2904 (UIApplication.m:2112)
11  UIKit                           0x188c665f0 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1684 (UIApplication.m:3355)
12  UIKit                           0x188c63764 -[UIApplication workspaceDidEndTransaction:] + 168 (UIApplication.m:2748)
13  FrontBoardServices              0x1851fb7ac __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36 (FBSSerialQueue.m:158)
14  FrontBoardServices              0x1851fb618 -[FBSSerialQueue _performNext] + 168 (FBSSerialQueue.m:177)
15  FrontBoardServices              0x1851fb9c8 -[FBSSerialQueue _performNextFromRunLoopSource] + 56 (FBSSerialQueue.m:206)
16  CoreFoundation                  0x18381109c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1761)
17  CoreFoundation                  0x183810b30 __CFRunLoopDoSources0 + 540 (CFRunLoop.c:1807)
18  CoreFoundation                  0x18380e830 __CFRunLoopRun + 724 (CFRunLoop.c:2536)
19  CoreFoundation                  0x183738c50 CFRunLoopRunSpecific + 384 (CFRunLoop.c:2814)
20  UIKit                           0x188a2b94c -[UIApplication _run] + 460 (UIApplication.m:2578)
21  UIKit                           0x188a26088 UIApplicationMain + 204 (UIApplication.m:3772)
22  Leio                            0x1000f6ecc main + 120 (BookInfoTableViewController.swift:19)
23  libdyld.dylib                   0x1832d68b8 start + 4 (start_glue.s:78)
+6

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


All Articles