簡體   English   中英

在nsmutablearray xcode中訪問圖像

[英]accessing images in nsmutablearray xcode

我正在將單個圖像轉換為UIImagePNGRepresentation,但我不斷收到線程斷點吃,讓data = UIImagePNGRepresentationation(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
        })

UIImage不是PFObject的子類,因此將其轉換tile as! UIImage tile as! UIImage永遠不會成功。 Swift編譯器應該已經向您發出警告:“從'PFObject'轉換為無關類型'UIImage'總是失敗”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM