I am getting crash reports from our users but I didn't understand the crash report.
我收到了用户的崩溃报告,但我不了解崩溃报告。
It says:
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
I am using swift. What is this report? My sendMessage
method:
我正在使用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")
}
How can I resolve it?
我该如何解决?
2 个解决方案
#1
2
You need to look at what the actual exception is. The most common is "unexpectedly found nil while unwrapping an Optional Value" which would suggest that you're passing a String!
to this method that was really nil
. But you need to start by looking at the exception message, not just the crash stack.
您需要查看实际异常是什么。最常见的是“在展开可选值时意外发现nil”,这表明你传递了一个字符串!对这种方法来说真的是零。但是您需要首先查看异常消息,而不仅仅是崩溃堆栈。
#2
1
Taken from here: https://forums.developer.apple.com/thread/6078
取自此处:https://forums.developer.apple.com/thread/6078
The message seems to correlate with passing a nil object to a swift function that expects non-nil object.
该消息似乎与将nil对象传递给期望非零对象的swift函数相关联。
So change your function signature to: func sendMessage(message: String?,to: String?,anonClosed: String?,toWeb: Int?)
or make sure it gets called with non-nil objects from Objective C
因此,将函数签名更改为:func sendMessage(message:String?,to:String?,anonClosed:String?,toWeb:Int?)或确保使用Objective C中的非零对象调用它
#1
2
You need to look at what the actual exception is. The most common is "unexpectedly found nil while unwrapping an Optional Value" which would suggest that you're passing a String!
to this method that was really nil
. But you need to start by looking at the exception message, not just the crash stack.
您需要查看实际异常是什么。最常见的是“在展开可选值时意外发现nil”,这表明你传递了一个字符串!对这种方法来说真的是零。但是您需要首先查看异常消息,而不仅仅是崩溃堆栈。
#2
1
Taken from here: https://forums.developer.apple.com/thread/6078
取自此处:https://forums.developer.apple.com/thread/6078
The message seems to correlate with passing a nil object to a swift function that expects non-nil object.
该消息似乎与将nil对象传递给期望非零对象的swift函数相关联。
So change your function signature to: func sendMessage(message: String?,to: String?,anonClosed: String?,toWeb: Int?)
or make sure it gets called with non-nil objects from Objective C
因此,将函数签名更改为:func sendMessage(message:String?,to:String?,anonClosed:String?,toWeb:Int?)或确保使用Objective C中的非零对象调用它