2016-11-21 60 views
0

錯誤的參數列表調用發生在這裏不能與type斯威夫特3

self.iotDataManager.register(withShadow: statusThingName, eventCallback: self.deviceShadowCallback) 

其中

let statusThingName="TemperatureStatus" 

func deviceShadowCallback(_ name:String!, operation:AWSIoTShadowOperationType, operationStatus:AWSIoTShadowOperationStatusType, clientToken:String!, payload:Data!) -> Void { 
    DispatchQueue.main.async { 
     //code 

    } 
} 

和簽名是

self.iotDataManager.register(withShadow: <String!>, eventCallback: { (<String?>, <AWSIoTShadowOperationType>, <AWSIoTShadowOperationStatusType>, <String?>, <Data?>) in 
       <code> 
      }) 

我認爲這可能是Swift中的一個錯誤,這是我正在嘗試修復的從Swift 2到3的轉換。

回答

0

的功能聲明:

func deviceShadowCallback(
          _ name: String?, 
          operation: AWSIoTShadowOperationType, 
          operationStatus: AWSIoTShadowOperationStatusType, 
          clientToken: String?, 
          payload: Data?) { 

} 

func register(
       withShadow: String, 
       eventCallback: (
           String?, 
           AWSIoTShadowOperationType, 
           AWSIoTShadowOperationStatusType, 
           String?, 
           Data?) -> Void) { 

} 

執行:

let statusThingName = "status" 
register(withShadow: statusThingName, eventCallback: deviceShadowCallback) 

我可以編譯和運行沒有任何問題了。

+0

可能是Xcode的問題,然後在我的情況。謝謝。 – Marin

+0

這個問題有什麼好運?同樣的事情發生在這裏...我的代碼看起來正確@Wilson – BrettStuart