现在好像花了两天的时间试图弄清楚为什么这个代码在明确它的范围内时仍然给我一个超出索引的错误。我正在尝试使用从heroku服务器下载的图像追加arrayOfCominedStyles [i]。
以下是代码,谢谢!
var arrayOfCombinedStyles = [[UIImage](), [UIImage](), [UIImage](), [UIImage]()]
let parseQuery = PFQuery(className: "Styles")
parseQuery.whereKey("username", equalTo: (PFUser.currentUser()?.username)!)
parseQuery.whereKey("status", equalTo: "READY")
parseQuery.limit = 1
parseQuery.findObjectsInBackgroundWithBlock { (objects, error) in
if let objects = objects {
for obj in objects {
for var i = 0; i < self.arrayOfCombinedStyles.count; i++ {
for var ii = 0; ii < arrayOfClientCount[i]; ii++ {
let imageData = obj["\(self.strr[i])\(ii+1)"] as! PFFile
imageData.getDataInBackgroundWithBlock({ (data, error) in
if error != nil {
//error here
}else {
if let data = data {
if let image = UIImage(data: data){
self.arrayOfCombinedStyles[i].append(image)
}
}
}
})
}
}
}
}else {
//error, you did not submit any
}
}