无法转换类型错误的值

时间:2017-03-10 04:30:17

标签: swift3

我需要帮助调试此错误

Cannot convert value of type 'PHContentEditingInput, [AnyHashable: Any]) -> Void' to expected argument type '(PHContentEditingInput?, [AnyHashable: Any]) -> Void'

以下是代码:

asset?.requestContentEditingInput(with: nil, completionHandler: {(_ contentEditingInput: PHContentEditingInput, _ info: [AnyHashable: Any]) -> Void in
 self.storageRef.child(filePath).putFile(imageFile, metadata: metadata, completion: {(_ metadata: FIRStorageMetadata, _ error: Error?) -> Void in
  if error != nil {
   return
  }
 })
})

1 个答案:

答案 0 :(得分:0)

?放在PHContentEditingInput的完成区contentEditingInput之后,因为它是可选类型。

asset?.requestContentEditingInput(with: nil, completionHandler: 
{(_ contentEditingInput: PHContentEditingInput?, _ info: [AnyHashable: Any]) -> Void in

    self.storageRef.child(filePath).putFile(imageFile, metadata: metadata, completion: {(_ metadata: FIRStorageMetadata, _ error: Error?) -> Void in
        if error != nil {
            return
        }
    })
})