2015-06-25 29 views
1

我與NSURLSession戰鬥上傳&下載,一切似乎如果不工作的事實,例如,在100個文件的背景發送(上傳)的:NSURLSession背景didCompleteWithError

- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error 
無論文件發送是否正確,系統都不總是調用

更是幾乎總是調用在會議結束...

這是正常的行爲,或我犯錯誤......?

我也做了一些使用AFNetworking的測試,但我總是得到相同的行爲。

謝謝!

+0

有同樣的問題。 – Avt

+0

您是否嘗試在創建新會話之前使會話無效?這就是答案:http://stackoverflow.com/questions/31262564/nsurlsession-didcompletewitherrorgets-called-with-nserror-is-nil/37240344#37240344 –

回答

0

在我的情況下委託方法func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?)雨燕3.0不叫,因爲它仍然依賴於Objective-C的。所以請使用下一代碼代表方法:

@objc(URLSession:task:didCompleteWithError:) 
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) { 
    //your code here 
}