以NSException类型的未捕获异常终止(lldb)

时间:2017-06-11 13:37:44

标签: swift xcode

我收到了一个错误, 以NSException类型的未捕获异常终止 (lldb)。 错误是 error

追溯是

2017-06-11 22:10:04.009 Kenshin_Swift[6073:541383] Unknown class PhotoController in Interface Builder file.
2017-06-11 22:10:04.120 Kenshin_Swift[6073:541383] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7fe830f06900> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key PhotoSelect.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001068efd4b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010635821e objc_exception_throw + 48
    2   CoreFoundation                      0x00000001068efc99 -[NSException raise] + 9
    3   Foundation                          0x0000000105c919df -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
    4   UIKit                               0x0000000106eae293 -[UIViewController setValue:forKey:] + 88
    5   UIKit                               0x000000010712279e -[UIRuntimeOutletConnection connect] + 109
    6   CoreFoundation                      0x00000001068949e0 -[NSArray makeObjectsPerformSelector:] + 256
    7   UIKit                               0x0000000107121122 -[UINib instantiateWithOwner:options:] + 1867
    8   UIKit                               0x0000000106eb49c5 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
    9   UIKit                               0x0000000106eb52e7 -[UIViewController loadView] + 177
    10  UIKit                               0x0000000106eb561c -[UIViewController loadViewIfRequired] + 201
    11  UIKit                               0x0000000106eb5e70 -[UIViewController view] + 27
    12  UIKit                               0x0000000106f144f3 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 483
    13  UIKit                               0x0000000106f13935 -[UITabBarController transitionFromViewController:toViewController:] + 59
    14  UIKit                               0x0000000106f0f7f6 -[UITabBarController _setSelectedViewController:] + 365
    15  UIKit                               0x0000000106f0f678 -[UITabBarController setSelectedViewController:] + 234
    16  UIKit                               0x0000000106dcd239 +[UIView(Animation) performWithoutAnimation:] + 90
    17  UIKit                               0x0000000106f09c14 -[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:] + 354
    18  UIKit                               0x0000000106f0ad8e -[UITabBarController viewWillAppear:] + 206
    19  UIKit                               0x0000000106ebb96f -[UIViewController _setViewAppearState:isAnimating:] + 692
    20  UIKit                               0x0000000106ebc07f -[UIViewController __viewWillAppear:] + 147
    21  UIKit                               0x0000000106ebd873 -[UIViewController viewWillMoveToWindow:] + 507
    22  UIKit                               0x0000000106dc3a87 -[UIView(Hierarchy) _willMoveToWindow:withAncestorView:] + 621
    23  UIKit                               0x0000000106dd485b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 451
    24  UIKit                               0x0000000106dc30d7 -[UIView(Hierarchy) addSubview:] + 838
    25  UIKit                               0x0000000106d7f7bf -[UIWindow addRootViewControllerViewIfPossible] + 849
    26  UIKit                               0x0000000106d7fc06 -[UIWindow _setHidden:forced:] + 293
    27  UIKit                               0x0000000106d93519 -[UIWindow makeKeyAndVisible] + 42
    28  UIKit                               0x0000000106d0bf8d -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4818
    29  UIKit                               0x0000000106d120ed -[UIApplication _runWithMainScene:transitionContext:completion:] + 1731
    30  UIKit                               0x0000000106d0f26d -[UIApplication workspaceDidEndTransaction:] + 188
    31  FrontBoardServices                  0x000000010a55d6cb __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24
    32  FrontBoardServices                  0x000000010a55d544 -[FBSSerialQueue _performNext] + 189
    33  FrontBoardServices                  0x000000010a55d8cd -[FBSSerialQueue _performNextFromRunLoopSource] + 45
    34  CoreFoundation                      0x0000000106894761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    35  CoreFoundation                      0x000000010687998c __CFRunLoopDoSources0 + 556
    36  CoreFoundation                      0x0000000106878e76 __CFRunLoopRun + 918
    37  CoreFoundation                      0x0000000106878884 CFRunLoopRunSpecific + 420
    38  UIKit                               0x0000000106d0daea -[UIApplication _run] + 434
    39  UIKit                               0x0000000106d13c68 UIApplicationMain + 159
    40  Kenshin_Swift                       0x0000000105b9f07f main + 111
    41  libdyld.dylib                       0x0000000109dc368d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

PhotoController是

import Foundation
import UIKit
class PhotoController:UIViewController,UINavigationControllerDelegate,UIImagePickerControllerDelegate{
    @IBOutlet weak var myImageView: UIImageView!
    @IBAction func PhotoSelect(_ sender: Any) {
            }

    @IBAction func PhotoSend(_ sender: Any) {
        let myPickerController = UIImagePickerController()
        myPickerController.delegate = self;
        myPickerController.sourceType = UIImagePickerControllerSourceType.photoLibrary

        self.present(myPickerController, animated: true, completion: nil)

    }
    func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])

    {
        myImageView.image = info[UIImagePickerControllerOriginalImage] as? UIImage

        self.dismiss(animated: true, completion: nil)

    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        //myImageUploadRequest()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }



  }

奥特莱斯是 outlet

我读了为什么会出现此错误消息。它说当“Outlet”出错时,会发生这种错误。但我不知道如何解决这个问题。我看到PhotoSelect和PhotoSend的出口了!,但我无法理解这个意思。我该怎么办?

1 个答案:

答案 0 :(得分:-1)

问题在于两个网点PhotoSelectPhotoSend。您可能不小心将其创建为@IBOutlet,删除了它们并将其重新创建为@IBAction

了解他们旁边是否有!。这意味着这些插座不再连接。因此,当您运行app时,您的故事板无法在视图控制器中找到这些插座,因此它会崩溃。

您需要点击x

删除这些商店