因此,爲了演示目的,我從我的xcassets中訪問了一系列圖像。我試圖用解析框架一次將150張圖像保存到我的解析服務器。這是我迄今爲止的代碼。我遇到的問題是我的應用程序cpu在測試中達到100%並下降到0.此外,圖像沒有保存到解析。我希望有人能幫我找到一種有效的方法來保存150張圖片進行解析。保存多個圖像進行分析
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
}
@IBAction func Continue(_ sender: Any) {
for imageName in imageNameList {
var objectForSave:PFObject = PFObject(className: "Clo")
let object:UIImage = UIImage(named: imageName)!
let tilesPF = imageNameList.map({ name in
let data = UIImagePNGRepresentation(object as! UIImage)!
let file = PFFile(data: data)
let tile = PFObject(className: "Tile")
tile["tile"] = file
})
objectForSave["tiles"] = tilesPF
objectForSave.saveInBackground(block: { responseObject, error in
//you'll want to save the object ID of the PFObject if you want to retrieve a specific image later
})
}
}
你可以在objective-c中處理答案嗎? – danh
是的,我會拿我所能得到的 – john
@danh你明白我的情況嗎 – john