i can't figure out why my array is out of bounds. i put the feed items into an array "imageArray" and it gives me fatal error heres code
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! BlogPost
let blogPost: BlogPost = blogPosts[indexPath.row]
cell.textLabel?.text = blogPost.postTitle
// cell.textLabel?.text = blogPost.postImageLink
if cell.postImage?.image == nil {
// let cache = ImageLoadingWithCache()
// cache.getImage(self.postImageLink, imageView: cell.postImage, defaultImage: "IMG_0079")}
if cell.postImage?.image == nil {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
// retrieve image from url
let image = UIImage(data: NSData(contentsOfURL: NSURL(string:self.postImageLink)!)!)
self.imageArray.append(image!)
dispatch_async(dispatch_get_main_queue(), { Void in
// set image in main thread
cell.postImage?.image = self.imageArray[indexPath.row]
})
}
} else {
cell.postImage?.image = UIImage(named: "IMG_0079")
}
}
return cell
}
specifically the error is here
cell.postImage?.image = self.imageArray[indexPath.row]
any ideas?