ios - 执行 segue 时线程 1 : signal SIGABRT,

标签 ios swift xcode error-handling runtime-error

<分区>

我有这个 Action 的按钮:

@IBAction func btnLogin(_ sender: Any) {
    if(userName.text! == "staff" && password.text! == "pass") {
            performSegue(withIdentifier: "showStaffPage", sender: self)
        } else if (userName.text! == "driver" && password.text! == "pass") {
            performSegue(withIdentifier: "showDriverPage", sender: self)
        } else if (userName.text! == "parent" && password.text! == "pass") {
            performSegue(withIdentifier: "showParentPage", sender: self)
        } else {
            errorMsg.alpha = 1;
        }
    }

它对“司机”和“ parent ”工作正常,但对“员工”给出以下错误。我已尝试清洁,并确保所有名称和位置均有效且仍然存在。不知道该尝试什么了。

2018-05-15 09:22:10.089411-0400 After School Tracker[12989:162055] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/user136086/Library/Developer/CoreSimulator/Devices/EE08864F-5D96-49E7-8E52-AFE0056A6BA2/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2018-05-15 09:22:10.089849-0400 After School Tracker[12989:162055] [MC] Reading from private effective user settings.
2018-05-15 09:22:20.767770-0400 After School Tracker[12989:162055] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<After_School_Tracker.StaffViewController 0x7fd191f16d80> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key viewHere.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010d1811e6 __exceptionPreprocess + 294
    1   libobjc.A.dylib                     0x000000010c816031 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010d1810b9 -[NSException raise] + 9
    3   Foundation                          0x000000010c237b47 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292
    4   UIKit                               0x000000010d799f20 -[UIViewController setValue:forKey:] + 87
    5   UIKit                               0x000000010da87d56 -[UIRuntimeOutletConnection connect] + 109
    6   CoreFoundation                      0x000000010d123e8d -[NSArray makeObjectsPerformSelector:] + 317
    7   UIKit                               0x000000010da86700 -[UINib instantiateWithOwner:options:] + 1856
    8   UIKit                               0x000000010d7a1137 -[UIViewController _loadViewFromNibNamed:bundle:] + 383
    9   UIKit                               0x000000010d7a1a64 -[UIViewController loadView] + 177
    10  UIKit                               0x000000010d7a1d81 -[UIViewController loadViewIfRequired] + 175
    11  UIKit                               0x000000010d7a25d4 -[UIViewController view] + 27
    12  UIKit                               0x000000010d7d3c6e -[UINavigationController _startCustomTransition:] + 945
    13  UIKit                               0x000000010d7ea5e2 -[UINavigationController _startDeferredTransitionIfNeeded:] + 714
    14  UIKit                               0x000000010d7eb8cc -[UINavigationController __viewWillLayoutSubviews] + 150
    15  UIKit                               0x000000010da43bd7 -[UILayoutContainerView layoutSubviews] + 231
    16  UIKit                               0x000000010d6cd808 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1515
    17  QuartzCore                          0x0000000113b7561a -[CALayer layoutSublayers] + 177
    18  QuartzCore                          0x0000000113b7982b _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 395
    19  QuartzCore                          0x0000000113b0029f _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 343
    20  QuartzCore                          0x0000000113b2d940 _ZN2CA11Transaction6commitEv + 568
    21  UIKit                               0x000000010d5f834f _UIApplicationFlushRunLoopCATransactionIfTooLate + 167
    22  UIKit                               0x000000010df5d532 __handleEventQueueInternal + 6875
    23  CoreFoundation                      0x000000010d123bb1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    24  CoreFoundation                      0x000000010d1084af __CFRunLoopDoSources0 + 271
    25  CoreFoundation                      0x000000010d107a6f __CFRunLoopRun + 1263
    26  CoreFoundation                      0x000000010d10730b CFRunLoopRunSpecific + 635
    27  GraphicsServices                    0x0000000112cfda73 GSEventRunModal + 62
    28  UIKit                               0x000000010d5fe0b7 UIApplicationMain + 159
    29  After School Tracker                0x000000010bef43b7 main + 55
    30  libdyld.dylib                       0x00000001115ec955 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

最佳答案

当 Storyboard Scene 有一个过时的 IBOutlet 到不再存在的东西时,就会发生这种情况。当我创建一个 IBOutlet,将它连接到 Interface Builder 中的某个东西,然后删除代码中关联的 IBOutlet 定义时,这种情况一直发生在我身上。不幸的是,这仅被确定为运行时问题(意味着编译器不会捕获它)。

在 Interface Builder 中打开 StaffViewController,然后打开 Connections Inspector 并查找仍然连接但已从中删除的 IBOutlet相关的代码文件。

关于ios - 执行 segue 时线程 1 : signal SIGABRT,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50351573/

相关文章:

iphone - 应用程序在后台时计划的 NSTimer?

iOS:iPad ImageView 中的底部缩略图栏

ios - 在 Swift 中分配来自其他类的函数

c - 为什么 Xcode C 编译器不能正确显示某些 ASCII 表字符?

android - 在 iOS、Android 和 WP 上开发的费用是多少?

ios - Swift 3 - 从图库中获取所有照片

ios - 将图像添加到 UIAlertController

iOS SceneKit 应用程序在 App 切换器模式下更快

iphone - 如何控制 UIWebView 的颜色(内容加载前)?

ios - iPhone X : unsafe area doesn't get color of the nearst view