0
我有以下代碼傳遞子類的變量sendSynchronousRequest方法:在夫特
var error : NSError?
var response : NSHTTPURLResponse?
var urlData : NSData = NSURLConnection.sendSynchronousRequest
(
request,
returningResponse: &response,
error: &error
) as NSData
returningResponse
採用如在參考文檔中提到的NSURLResponse
一個實例。
Im使用NSHTTPURLResponse
這是NSURLResponse
的子類。這在Objective-C中工作正常,但我不知道如何在Swift中編寫它,因爲編譯器會在該行中引發錯誤。
的錯誤是: Cannot convert the expression's type 'NSData' to type 'inout NSHTTPURLResponse'
這是什麼意思?以及如何讓它正確?
謝謝男人。爲我節省了很多時間 –