Command failed due to signal: Abort trap: 6

前端 未结 30 2640
暖寄归人
暖寄归人 2020-12-01 08:56

Since Xcode 7 and Swift 2.0, I get the error above, like in the screenshot shown here:

\"screenshot

30条回答
  •  悲&欢浪女
    2020-12-01 09:47

    In my case i had @objc protocol with optional methods and when i called its methods also in swift class i got that error, after removing the optional keyword from functions in the protocol the error was gone.

    before (with error):

    @objc protocol SomeDelegate:NSObjectProtocol{
    
        optional func someDelegateMethod()
    }
    
    class MySwiftClass{
        func notifyMyDelegate(){
            mydelegate?.someDelegateMethod?() //this line caused the error
        }
    }
    

    after:

    @objc protocol SomeDelegate:NSObjectProtocol{
    
        func someDelegateMethod()
    }
    
    class MySwiftClass{
        func notifyMyDelegate(){
            mydelegate?.someDelegateMethod()
        }
    }
    

提交回复
热议问题