【发布时间】:2015-10-18 11:34:11
【问题描述】:
我遇到的错误:
1) 调用中的额外参数“错误”
2) 无法转换“inout NSError?”类型的值? (又名 'inout Optional')到预期的参数类型 '()'
我的代码:
func initUdpSocket(){
var error : NSError?
mUdpSocket = GCDAsyncUdpSocket(delegate: self, delegateQueue: dispatch_get_main_queue())
mUdpSocket.enableBroadcast(true,error: &error)
mUdpSocket.beginReceiving(&error)
}
func udpSocket(sock: GCDAsyncUdpSocket!, didReceiveData data: NSData!, fromAddress address: NSData!, withFilterContext filterContext: AnyObject!) {
print("\(__FUNCTION__),\(__LINE__),\(data)");
}
func udpSocket(sock: GCDAsyncUdpSocket!, didSendDataWithTag tag: Int) {
print("\(__FUNCTION__),\(__LINE__),\(tag)");
}
func udpSocket(sock: GCDAsyncUdpSocket!, didConnectToAddress address: NSData!) {
print("\(__FUNCTION__),\(__LINE__),\(address)");
}
func udpSocket(sock: GCDAsyncUdpSocket!, didNotConnect error: NSError!) {
print("\(__FUNCTION__),\(__LINE__),\(error)");
}
}
我可以知道我的代码有什么问题吗?在更新我的 xcode 之前,我没有任何错误。
【问题讨论】:
-
Swift 2——我猜你说的是 Swift 2——引入了一种新的错误处理语法。语言指南中对此进行了描述
标签: swift