Код: Выделить всё
func handlePhotoDownloadCompletion(notification : NSNotification) {
let userInfo:Dictionary = notification.userInfo as! Dictionary
let id = userInfo["id"]
let index = users_cities.indexOf({$0.id == id})
if index != nil {
let indexPath = NSIndexPath(forRow: index!, inSection: 0)
let cell = followedCollectionView.cellForItemAtIndexPath(indexPath) as! FeaturedCitiesCollectionViewCell
if (users_cities[index!].image != nil) {
cell.backgroundImageView.image = users_cities[index!].image!
}
}
}
Код: Выделить всё
fatal error: unexpectedly found nil while unwrapping an Optional value
Код: Выделить всё
let cell = followedCollectionView.cellForItemAtIndexPath(indexPath) as! FeaturedCitiesCollectionViewCell
Отсюда и мой вопрос: как я могу изменить эту функцию, чтобы проверить, видна ли в данный момент ячейка, с которой мы имеем дело, или нет. Я знаю о коллекцииView.visibleCells(), однако не знаю, как ее здесь применить.
Подробнее здесь: https://stackoverflow.com/questions/382 ... ectionview