我正在尝试使用DKimagepickercontroller上传图片,这是一种将其上传到网址的方法,但我混淆了我想要放入@Pattern(regexp = "\\s*|.{5,10}")
private String couponCode;
completeBlock: (success: Bool) - Void
这是我在xcode中编写的代码
func writeImageToFile(path: String, completeBlock: (success: Bool) -> Void){
}
但我得到了这个错误
let apath = "http://localhost/swift/upload.php"
writeImageToFile(apath,completeBlock: (success: false) -> Void)
答案 0 :(得分:0)
你必须像writeImageToFile(path) { success in print(success) }
答案 1 :(得分:0)
该块应该用作尾随闭包,不要将其留在签名中。
在Xcode中看起来像这样:stackoverflow.com/a/33020097/2227743
一旦任务完成,就会使用closure参数,在你的情况下,它将指示文件是否已被写入。
您可以在闭包中测试success
:
writeImageToFile(somePath) { (success) in
if success {
// the file has been written
} else {
// the file hasn't been written
}
}