gpt4 book ai didi

ios - 带有进度的 saveInBackgroundWithBlock 在 Xcode 6.3 下的 Swift 中不起作用

转载 作者:行者123 更新时间:2023-11-28 13:14:25 25 4
gpt4 key购买 nike

我从 parse.com 网站获得的以下代码不起作用:

let str = "Working at Parse is great!"
let data = str.dataUsingEncoding(NSUTF8StringEncoding)
let file = PFFile(name:"resume.txt", data:data)
file.saveInBackgroundWithBlock {
(succeeded: Bool!, error: NSError!) -> Void in
// Handle success or failure here ...
}, progressBlock: {
(percentDone: Int) -> Void in
// Update your progress spinner here. percentDone will be between 0 and 100.
}

错误信息是:

Cannot invoke 'saveInBackgroundWithBlock' with an argument list of type '((Bool, NSError?) -> Void?, progressBlock: (Int) -> Void?)'

我尝试了不同的组合,但都没有用。任何想法?谢谢

最佳答案

在 IOS 8.3 中,以下代码段有效:

let str = "Working at Parse is great!"
let data = str.dataUsingEncoding(NSUTF8StringEncoding)
let file = PFFile(name:"resume.txt", data:data!)

file.saveInBackgroundWithBlock({ (succeeded: Bool, error: NSError?) -> Void in
// Handle success or failure here ...
if succeeded {
println("Save successful")
} else {
println("Save unsuccessful: \(error?.userInfo)")
}

}, progressBlock: { (percentDone: Int32) -> Void in
// Update your progress spinner here. percentDone will be between 0 and 100.
})

让我知道这是否适合您。

关于ios - 带有进度的 saveInBackgroundWithBlock 在 Xcode 6.3 下的 Swift 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29657026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com