功能签名专业化在swift中崩溃

时间:2015-09-18 15:55:11

标签: ios swift

我收到了用户的崩溃报告,但我并不了解崩溃报告。

它说:

Ribony: function signature specialization <Arg[0] = Owned To Guaranteed and Exploded, Arg[1] = Owned To Guaranteed and Exploded, Arg[2] = Owned To Guaranteed and Exploded, Arg[3] = Exploded, Arg[4] = Owned To Guaranteed> of Ribony.ChatManager.sendMessage (Ribony.ChatManager)(Swift.String, to : Swift.String, anonClosed : Swift.String, toWeb : Swift.Int) -> () + 3608

enter image description here

我正在使用swift。这是什么报告?我的sendMessage方法:

func sendMessage(message: String,to: String,anonClosed: String,toWeb: Int) {
        NSNotificationCenter.defaultCenter().postNotificationName(mySpecialNotificationKey, object: self,userInfo:["message":message])
        var sender=""
        var token=""
        var toSubstr=""
        if count(to) >= 5 {
            let rangeOfTo = Range(start: to.startIndex,
            end: advance(to.startIndex, 5))
            toSubstr = to.substringWithRange(rangeOfTo)
        }else{
            toSubstr=to
        }
        socket.emit("sendMessage","ok")
}

我该如何解决?

2 个答案:

答案 0 :(得分:2)

您需要查看实际异常是什么。最常见的是&#34;意外地发现nil,同时打开一个可选值&#34;这表明您已将String!传递给真正nil的此方法。但是你需要从查看异常消息开始,而不仅仅是崩溃堆栈。

答案 1 :(得分:1)

从这里采取:https://forums.developer.apple.com/thread/6078

该消息似乎与将nil对象传递给期望非零对象的swift函数相关。

因此,请将您的功能签名更改为: func sendMessage(message: String?,to: String?,anonClosed: String?,toWeb: Int?)或确保使用Objective C中的非零对象调用它