的錯誤我得到:無法轉換類型'inout NSError?'的值
1)額外的參數 '錯誤' 呼叫
2)無法將類型的價值「INOUT NSError? (又名「INOUT可選」)預期的參數類型「()」
我的代碼:
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 - 介紹一種新的錯誤處理語法。這在語言指南中有描述 – vadian