线程1:信号SIGBART按钮错误

时间:2016-12-29 14:37:08

标签: swift xcode

2016-12-29 11:03:12.874 Albhabet City 1[9872:259138] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Albhabet_City_1.IntroViewController 0x7fcf8ec14d60> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key play.'
*** First throw call stack:
(
	0   CoreFoundation                      0x0000000103c69d4b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x000000010336221e objc_exception_throw + 48
	2   CoreFoundation                      0x0000000103c69c99 -[NSException raise] + 9
	3   Foundation                          0x0000000102e709df -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
	4   UIKit                               0x0000000104228293 -[UIViewController setValue:forKey:] + 88
	5   UIKit                               0x000000010449c79e -[UIRuntimeOutletConnection connect] + 109
	6   CoreFoundation                      0x0000000103c0e9e0 -[NSArray makeObjectsPerformSelector:] + 256
	7   UIKit                               0x000000010449b122 -[UINib instantiateWithOwner:options:] + 1867
	8   UIKit                               0x000000010422e9c5 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
	9   UIKit                               0x000000010422f2e7 -[UIViewController loadView] + 177
	10  UIKit                               0x000000010422f61c -[UIViewController loadViewIfRequired] + 201
	11  UIKit                               0x000000010422fe70 -[UIViewController view] + 27
	12  UIKit                               0x0000000104af06a4 -[_UIFullscreenPresentationController _setPresentedViewController:] + 87
	13  UIKit                               0x000000010420a702 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 141
	14  UIKit                               0x0000000104242e97 -[UIViewController _presentViewController:withAnimationController:completion:] + 3956
	15  UIKit                               0x000000010424626b -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 530
	16  UIKit                               0x0000000104245d51 -[UIViewController presentViewController:animated:completion:] + 179
	17  UIKit                               0x000000010424b41e -[UIViewController _showViewController:withAction:sender:] + 274
	18  UIKit                               0x0000000104708fcc __66-[UIStoryboardShowSegueTemplate newDefaultPerformHandlerForSegue:]_block_invoke + 134
	19  UIKit                               0x00000001048631dd -[UIStoryboardSegueTemplate _performWithDestinationViewController:sender:] + 447
	20  UIKit                               0x0000000104862fed -[UIStoryboardSegueTemplate _perform:] + 82
	21  UIKit                               0x00000001048632af -[UIStoryboardSegueTemplate perform:] + 156
	22  UIKit                               0x000000010408f8bc -[UIApplication sendAction:to:from:forEvent:] + 83
	23  UIKit                               0x0000000104215c38 -[UIControl sendAction:to:forEvent:] + 67
	24  UIKit                               0x0000000104215f51 -[UIControl _sendActionsForEvents:withEvent:] + 444
	25  UIKit                               0x0000000104214e4d -[UIControl touchesEnded:withEvent:] + 668
	26  UIKit                               0x00000001040fd545 -[UIWindow _sendTouchesForEvent:] + 2747
	27  UIKit                               0x00000001040fec33 -[UIWindow sendEvent:] + 4011
	28  UIKit                               0x00000001040ab9ab -[UIApplication sendEvent:] + 371
	29  UIKit                               0x000000010489872d __dispatchPreprocessedEventFromEventQueue + 3248
	30  UIKit                               0x0000000104891463 __handleEventQueue + 4879
	31  CoreFoundation                      0x0000000103c0e761 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	32  CoreFoundation                      0x0000000103bf398c __CFRunLoopDoSources0 + 556
	33  CoreFoundation                      0x0000000103bf2e76 __CFRunLoopRun + 918
	34  CoreFoundation                      0x0000000103bf2884 CFRunLoopRunSpecific + 420
	35  GraphicsServices                    0x0000000109cc2a6f GSEventRunModal + 161
	36  UIKit                               0x000000010408dc68 UIApplicationMain + 159
	37  Albhabet City 1                     0x0000000102d7adbf main + 111
	38  libdyld.dylib                       0x000000010734868d start + 1
	39  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
上面的页面是我收到的错误

import UIKit
import AVFoundation

class IntroViewController: UIViewController {

    var player:AVAudioPlayer = AVAudioPlayer()


    @IBAction func play(_ sender: Any)
    {
    player.play()
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        
        
        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
        
        do
        {
            let audioPath = Bundle.main.path(forResource: "song", ofType: "mp3")
            try player = AVAudioPlayer(contentsOf: NSURL(fileURLWithPath: audioPath!) as URL)
            
            
        }
        catch
        {
            //error
        }

    
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

当我点击手机模拟器上的按钮时,这个页面无法显示。

我正在制作一个有多个场景的应用。每当我点击我的第一个按钮到我的模拟器上的另一张幻灯片时,它就会切换到“AppDelegate.swift”并在“class app delegate ...”上它给出了错误“thread 1:signal SIGBART。The errorthe failed simulator

1 个答案:

答案 0 :(得分:0)

如果断开IB与代码之间的连接,通常会发生SIGABRT错误。例如,如果您从按钮到@IBAction建立了一个动作连接并将其删除,那么它将导致SIGABRT。如果删除按钮然后建立新连接并重写代码,则可以修复它。

以下是您可以查看的链接: SIGABRT Explained! (General Solution) - Youtube