gpt4 book ai didi

ios - EXC_BAD_INSTRUCTION 尝试从 Parse 获取图像时

转载 作者:行者123 更新时间:2023-11-29 02:08:13 24 4
gpt4 key购买 nike

我在以下行中收到以下错误:“let imgFile = object["imageFile"] as PFFile

代码:

func getRightLevelInfo() {
var query = PFQuery(className: "userstatus")
query.whereKey("username", equalTo: PFUser.currentUser().username)
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
println("Found something")
for object in objects {
println(object.objectId)

let lastSuccessfulLevel = object["lastSuccessfulLevel"] as Int
let nextLevel = lastSuccessfulLevel + 1
let score = object["score"] as Int

println("lastSuccessfulLevel = " + String(lastSuccessfulLevel) + ", Score = " + String(score))

var queryLevel = PFQuery(className: "puzzledata")
queryLevel.whereKey("lastleveldone", equalTo: String(nextLevel))
queryLevel.findObjectsInBackgroundWithBlock {
(levels: [AnyObject]!, error: NSError!) -> Void in
if error == nil {

for level in levels {
self.wordAnswer = level["wordAnswer"] as String
self.wordJumbled = level["wordJumbled"] as String

println("For this level, wordAnswer = " + self.wordAnswer + ", wordJumbled = " + self.wordJumbled)

let imgFile = object["imageFile"] as PFFile


imgFile.getDataInBackgroundWithBlock({
(imageData: NSData!, error: NSError!) -> Void in
if (error == nil) {
let image = UIImage(data:imageData)?
println("Got Image Successfully")

} else {
println("ERROR in getting image")
}

})//getDataInBackgroundWithBlock - end

}

} else {
println("%@", error) //couldn't find level data
}
}


}
}
else {
println("%@", error)
}
}
}

我遇到的运行时错误:

enter image description here

虽然错误出现在“let imgFile = object["imageFile"] as PFFile”这一行,但您也可以看到解析数据库类确实具有名称完全相同的字段” img文件

enter image description here

最佳答案

它看起来像一个错字,你应该替换它

let imgFile = object["imageFile"] as PFFile

let imgFile = level["imageFile"] as PFFile

关于ios - EXC_BAD_INSTRUCTION 尝试从 Parse 获取图像时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29566228/

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