导致错误的IB出口和动作线程1:信号Sigabrt

时间:2017-12-28 22:00:12

标签: ios swift xcode sigabrt

我目前正在通过Xcode为iPhone创建一个健身应用程序。它有三个不同的视图控制器和一个附加到每个控制器的文件。我目前正在使用第二个文件在第二个视图控制器中工作,我目前只在代码中添加了四个IB插座,并为按钮添加了IB操作。然而,当我运行代码时,它在模拟器中冻结并带我回到AppDelegate类的屏幕,它有一个红色区域,表示Signal Sigabrt。当我删除所有插座和动作时,程序运行正常,一切正常,但当我添加一个插座时,模拟器再次冻结,信号Sigabrt再次返回。我在许多其他帖子中在线阅读,这是因为元素与出口和操作之间存在连接问题,因此我通过Connections Inspector删除了操作和出口,并重新连接了所有内容。然而,这并没有解决任何问题,我仍然坚持使用相同的Signal Sigabrt问题。我查看了调试器给我的内容,它说Breakfast1插座错误,所以我通过Connections检查器删除了该插座并再次运行程序,但它只是告诉我下一个插座是错了,它再次给了我信号Sigabrt。有没有其他人有这个问题,可以帮我解决吗?

我的ViewController2代码:

import UIKit
class ViewController2: UIViewController {
    @IBOutlet weak var Breakfast1: UITextField!
    @IBOutlet weak var Lunch1: UITextField!
    @IBOutlet weak var Dinner1: UITextField!
    @IBOutlet weak var Total1: UILabel!


    override func viewDidLoad() {
        super.viewDidLoad()
        /
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        /
    }

    @IBAction func addingButton(_ sender: Any) {
    }

}

Debug区域给了我什么:

2017-12-28 14:06:03.645843-0700 Fitness App FBLA[96716:47605553] Unknown class ViewController2 in Interface Builder file.
2017-12-28 14:06:03.658340-0700 Fitness App FBLA[96716:47605553] [MC] Lazy loading NSBundle MobileCoreServices.framework
2017-12-28 14:06:03.659452-0700 Fitness App FBLA[96716:47605553] [MC] Loaded MobileCoreServices.framework
2017-12-28 14:06:03.692388-0700 Fitness App FBLA[96716:47605553] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/basketballboy03/Library/Developer/CoreSimulator/Devices/8342977F-88AA-474E-BDEB-EAABE8007D1C/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-12-28 14:06:03.749797-0700 Fitness App FBLA[96716:47605553] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7fa6e3417c40> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Breakfast1.'
*** First throw call stack:
(
  0   CoreFoundation                      0x000000010cd4b1ab __exceptionPreprocess + 171
  1   libobjc.A.dylib                     0x00000001090f3f41 objc_exception_throw + 48
  2   CoreFoundation                      0x000000010cd4b0f9 -[NSException raise] + 9
  3   Foundation                          0x0000000108b161e3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292
  4   UIKit                               0x0000000109b2d777 -[UIViewController setValue:forKey:] + 87
  5   UIKit                               0x0000000109e1ccb1 -[UIRuntimeOutletConnection connect] + 109
  6   CoreFoundation                      0x000000010ccee4fd -[NSArray makeObjectsPerformSelector:] + 317
  7   UIKit                               0x0000000109e1b667 -[UINib instantiateWithOwner:options:] + 1856
  8   UIKit                               0x0000000109b34838 -[UIViewController _loadViewFromNibNamed:bundle:] + 383
  9   UIKit                               0x0000000109b35164 -[UIViewController loadView] + 177
  10  UIKit                               0x0000000109b35495 -[UIViewController loadViewIfRequired] + 195
  11  UIKit                               0x0000000109b35cf2 -[UIViewController view] + 27
  12  UIKit                               0x000000010a5c53a9 -[_UIFullscreenPresentationController _setPresentedViewController:] + 89
  13  UIKit                               0x0000000109b03ba7 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 133
  14  UIKit                               0x0000000109b48f6a -[UIViewController _presentViewController:withAnimationController:completion:] + 3808
  15  UIKit                               0x0000000109b4bdad __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 99
  16  UIKit                               0x0000000109b4c47d -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 532
  17  UIKit                               0x0000000109b4bd0c -[UIViewController _presentViewController:animated:completion:] + 181
  18  UIKit                               0x0000000109b4c06b -[UIViewController presentViewController:animated:completion:] + 159
  19  UIKit                               0x000000010a297cbc __74-[UIStoryboardPresentationSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 133
  20  UIKit                               0x000000010a2b7dcb -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 279
  21  UIKit                               0x000000010a2b7c83 -[UIStoryboardSegueTemplate _perform:] + 82
  22  UIKit                               0x000000010a2b7f4b -[UIStoryboardSegueTemplate perform:] + 157
  23  UIKit                               0x0000000109992275 -[UIApplication sendAction:to:from:forEvent:] + 83
  24  UIKit                               0x0000000109b0f4a2 -[UIControl sendAction:to:forEvent:] + 67
  25  UIKit                               0x0000000109b0f7bf -[UIControl _sendActionsForEvents:withEvent:] + 450
  26  UIKit                               0x0000000109b0e6ec -[UIControl touchesEnded:withEvent:] + 618
  27  UIKit                               0x0000000109a07bbb -[UIWindow _sendTouchesForEvent:] + 2807
  28  UIKit                               0x0000000109a092de -[UIWindow sendEvent:] + 4124
  29  UIKit                               0x00000001099ace36 -[UIApplication sendEvent:] + 352
  30  UIKit                               0x000000010a2ef434 __dispatchPreprocessedEventFromEventQueue + 2809
  31  UIKit                               0x000000010a2f2089 __handleEventQueueInternal + 5957
  32  CoreFoundation                      0x000000010ccee231 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
  33  CoreFoundation                      0x000000010cd8de41 __CFRunLoopDoSource0 + 81
  34  CoreFoundation                      0x000000010ccd2b49 __CFRunLoopDoSources0 + 185
  35  CoreFoundation                      0x000000010ccd212f __CFRunLoopRun + 1279
  36  CoreFoundation                      0x000000010ccd19b9 CFRunLoopRunSpecific + 409
  37  GraphicsServices                    0x000000010f4b39c6 GSEventRunModal + 62
  38  UIKit                               0x00000001099905e8 UIApplicationMain + 159
  39  Fitness App FBLA                    0x00000001087dcbf7 main + 55
  40  libdyld.dylib                       0x000000010de77d81 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

3 个答案:

答案 0 :(得分:2)

看起来您没有在Interface Builder中为视图控制器设置正确的类。

选择视图控制器后,在Identity Inspector的Interface Builder右侧将类设置为ViewController2。

enter image description here

答案 1 :(得分:0)

我有同样的问题。但是,当我创建一个新的可可文件并将其添加到ViewController时,它已解决。似乎该文件已损坏,因为它可能会在运行后继续在代码的侧面添加那些灰色圆圈。

答案 2 :(得分:-1)

好吧,看起来您可能只是使用其中一个Xcode编辑器重命名了其中一个插座,但这会破坏插座与实际按钮/标签的连接。要解决此问题,请打开swift文件,表明您的源代码存在问题并在其中编辑名称。这将解决您在IBOutlet之间的中断。我希望这可以工作lmk,如果它没有,我可以帮助你。

康纳