gpt4 book ai didi

objective-c - Storyboard崩溃 OSX

转载 作者:行者123 更新时间:2023-12-03 17:19:28 25 4
gpt4 key购买 nike

我发现这次崩溃是非常随机发生的:

Fatal Exception: NSInvalidArgumentException
*** setObjectForKey: object cannot be nil (key: NSViewController-Qmf-WE-Bmb)
0 CoreFoundation 0x7fff95e504da __exceptionPreprocess
1 libobjc.A.dylib 0x7fff923eef7e objc_exception_throw
2 CoreFoundation 0x7fff95d4a414 -[__NSDictionaryM setObject:forKey:]
3 AppKit 0x7fff9857f917 -[NSStoryboard nibForControllerWithIdentifier:]
4 AppKit 0x7fff9857fc11 -[NSStoryboard instantiateControllerWithIdentifier:]
5 AppKit 0x7fff982e733b -[NSStoryboardSegueTemplate _perform:]
6 AppKit 0x7fff983345d7 -[NSViewController performSegueWithIdentifier:sender:]
7 libdispatch.dylib 0x7fff8e5cc93d _dispatch_call_block_and_release
8 libdispatch.dylib 0x7fff8e5c140b _dispatch_client_callout
9 libdispatch.dylib 0x7fff8e5d4c1c _dispatch_main_queue_callback_4CF
10 CoreFoundation 0x7fff95e059e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
11 CoreFoundation 0x7fff95dc48dd __CFRunLoopRun
12 CoreFoundation 0x7fff95dc3ed8 CFRunLoopRunSpecific
13 HIToolbox 0x7fff99b4b935 RunCurrentEventLoopInMode
14 HIToolbox 0x7fff99b4b76f ReceiveNextEventCommon
15 HIToolbox 0x7fff99b4b5af _BlockUntilNextEventMatchingListInModeWithFilter
16 AppKit 0x7fff97e3bdf6 _DPSNextEvent
17 AppKit 0x7fff97e3b226 -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
18 AppKit 0x7fff97e2fd80 -[NSApplication run]
19 AppKit 0x7fff97df9368 NSApplicationMain
20 libdyld.dylib 0x7fff8c6875ad start

我已验证 Segue 标识符是否正确,并且 Storyboard 存在并包含 Segue。我还验证了存在 ID 为 Qmf-WE-Bmb 的 View Controller 。

有任何线索说明为什么会发生这种情况吗?这是否意味着源 VC 已被释放或者无法加载目标 VC?

最佳答案

如果有人遇到同样的问题,我通过在基本 Controller 上用自定义函数替换 performSegueWithIdentifier: 来避免崩溃:

- (void)performManualSegueWithControllerID:(NSString *)identifier {
if ([NSThread isMainThread]) {
NSViewController *controller = [self.storyboard instantiateControllerWithIdentifier:identifier];
if (controller) {
MyCustomAnimator *animator = [[MyCustomAnimator alloc] init];
[animator setAnimateVertically:NO];
[self prepareForManualSegueToController:controller];
[self presentViewController:controller animator:animator];
} else {
// Some Error
}
} else {
[self performSelectorOnMainThread:@selector(performManualSegueWithControllerID:)
withObject:identifier
waitUntilDone:NO];
}
}

- (void)prepareForManualSegueToController:(NSViewController *)controller {

}

关于objective-c - Storyboard崩溃 OSX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39362467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com