简体   繁体   English

在nsmutablearray xcode中访问图像

[英]accessing images in nsmutablearray xcode

I am converting individual images into UIImagePNGRepresentation but I keep getting a thread breakpoin ate let data = UIImagePNGRepresentation(tile as! UIImage)! 我正在将单个图像转换为UIImagePNGRepresentation,但我不断收到线程断点吃,让data = UIImagePNGRepresentationation(tile as!UIImage)! ImageNameList is an nsmutablearray of images 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
        })

UIImage is not a subclass of PFObject , so the cast tile as! UIImage UIImage不是PFObject的子类,因此将其转换tile as! UIImage tile as! UIImage can never be successful. tile as! UIImage永远不会成功。 The Swift compiler should already be giving you a warning: “Cast from 'PFObject' to unrelated type 'UIImage' always fails”. Swift编译器应该已经向您发出警告:“从'PFObject'转换为无关类型'UIImage'总是失败”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM