0

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

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
        })
4

1 回答 1

0

UIImage不是 的子类PFObject,因此强制转换tile as! UIImage永远不会成功。Swift 编译器应该已经给你一个警告:“从 'PFObject' 转换为不相关的类型 'UIImage' 总是失败”。

于 2017-03-04T19:28:27.340 回答