gpt4 book ai didi

ios - 访问 nsmutablearray xcode 中的图像

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

我正在将单个图像转换为 UIImagePNGRepresentation,但我不断收到线程断点 ate let data = UIImagePNGRepresentation(tile as! UIImage)! ImageNameList 是一个 nsmutable 图像数组

var imageNameList: [String] {
var imageNameList2:[String] = [] //[NSMutableArray]()
for i in 0...149 {
let imageName = String(format: "pic_%03d", Int(i))
imageNameList2.append(imageName)
}
return imageNameList2
}

let table = PFObject(className: "Cool")
let tilesPF = imageNameList.map({ tile in
let data = UIImagePNGRepresentation(tile)! //cannot convert type string to type uiimage
let file = PFFile(data: data)

let tile = PFObject(className: "RealCool")
tile["tile"] = file
})

最佳答案

UIImage不是 PFObject 的子类,所以 Actor tile as! UIImage永远不可能成功。 Swift 编译器应该已经向您发出警告:“从 'PFObject' 转换为不相关类型 'UIImage' 总是失败”。

关于ios - 访问 nsmutablearray xcode 中的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42600314/

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