2016-10-04 158 views
0

我有點困惑如何使用斯威夫特3.以前完成處理,在雨燕2.2,我有這樣的代碼:CompletionHandler斯威夫特3

transferUtility.uploadFile(tmpFileURL, bucket: bucket, key: key, contentType: contentType, expression: nil, completionHander: { (task, error) in 
        self.uploadCompletionHandler(task, transferError: error) 
}) 

我如何端口這斯威夫特3?

我得到一個錯誤,指出Cannot convert value of type '(AWSS3TransferUtilityUploadTask, NSError) ->()' to expected argument type 'AWSS3TransferUtilityUploadCompletionHandlerBlock?'

有誰知道什麼地方出錯了?

回答

0

檢查AWSS3TransferUtilityUploadCompletionHandlerBlock的簽名,現在Swift 3不允許自動類型轉換。 Swift 3不允許你用不同的簽名來定義completionBlock,請檢查? and !

+0

它是'FUNC uploadFile開(_ fileURL:URL,桶:字符串,鍵:字符串,則contentType:字符串,表達式:AWSS3TransferUtilityUploadExpression ?, completionHander completionHandler:AWSS3.AWSS3TransferUtilityUploadCompletionHandlerBlock =無) - > AWSTask ' – hockeybro

+0

這裏是'AWS3TransferUtilityUploadCompletionHandlerBlock':'公開的typealias AWSS3TransferUtilityUploadCompletionHandlerBlock =(AWSS3TransferUtilityUploadTask,Error?) - > Swift.Void ' – hockeybro

+0

'嘗試'(任務,錯誤?)' –