无法转换类型的值
Cannot convert value of type
在我的项目中,我使用 Cloudinary,而我在 Xcode 7.3 中使用以下函数时它工作正常但是在 Xcode 8 中我遇到了错误。
(Cannot convert value of type ([AnyHashable: Any]!,String!,Int!,AnyObject) -> () to expected argument type (CLUploaderCompletion).
如何解决这个错误。
uploader.upload(forUpload, options: nil, withCompletion:onCloudinaryCompletion, andProgress:onCloudinaryProgress)
func onCloudinaryCompletion(_ successResult:[AnyHashable: Any]!, errorResult:String!, code:Int, idContext:AnyObject!) {
print("successResult\(successResult)")
}
func onCloudinaryProgress(_ bytesWritten:Int, totalBytesWritten:Int, totalBytesExpectedToWrite:Int, idContext:AnyObject!) {
print("onCloudinaryProgress")
}
错误的屏幕截图:
在 swift 3 中有些事情发生了变化,其中之一是 objective c 中的 id
现在 swift 中的 Any
而不是 AnyObject
。将您的 idContext
更改为键入 Any
.
此外,您还必须将字典的类型和字符串更改为可选。所以它变成了 String?
和 [AnyHashable: Any]?
.
在我的项目中,我使用 Cloudinary,而我在 Xcode 7.3 中使用以下函数时它工作正常但是在 Xcode 8 中我遇到了错误。
(Cannot convert value of type ([AnyHashable: Any]!,String!,Int!,AnyObject) -> () to expected argument type (CLUploaderCompletion).
如何解决这个错误。
uploader.upload(forUpload, options: nil, withCompletion:onCloudinaryCompletion, andProgress:onCloudinaryProgress)
func onCloudinaryCompletion(_ successResult:[AnyHashable: Any]!, errorResult:String!, code:Int, idContext:AnyObject!) {
print("successResult\(successResult)")
}
func onCloudinaryProgress(_ bytesWritten:Int, totalBytesWritten:Int, totalBytesExpectedToWrite:Int, idContext:AnyObject!) {
print("onCloudinaryProgress")
}
错误的屏幕截图:
在 swift 3 中有些事情发生了变化,其中之一是 objective c 中的 id
现在 swift 中的 Any
而不是 AnyObject
。将您的 idContext
更改为键入 Any
.
此外,您还必须将字典的类型和字符串更改为可选。所以它变成了 String?
和 [AnyHashable: Any]?
.