我正在尝试追加从解析数据库中检索到的图像,但是没有任何内容添加到UIImage数组中。如何附加检索到的图像?
var arrayOfFriends: [UIImage] = []
func getFriendPic(){
var imagequery = PFQuery(className: "_User")
imagequery.findObjectsInBackgroundWithBlock {( objects: [AnyObject]?, error: NSError?) -> Void in
for object in objects!{
let userPic = object["ProPic"] as! PFFile
userPic.getDataInBackgroundWithBlock({ (imageData: NSData?, error: NSError?) -> Void in
if(error == nil){
let image = UIImage(data: imageData!)
//breakpoint placed on line below, but app crashes with array out of bounds.
self.arrayOfFriends.append(image!)
print(self.arrayOfFriends)
}
dispatch_async(dispatch_get_main_queue()) {
self.collectionView.reloadData()
}
})
}
}
}
答案 0 :(得分:0)
代码不是问题,它是Xcode,这是任何遇到同样问题的人的解决方案。 The resource could not be loaded because the App Transport Security policy requires the use of a secure connection