var cellHeights: [CGFloat] = [CGFloat]()
if let height = self.cellHeights[index] as? CGFloat {
self.cellHeights[index] = cell.frame.size.height
} else {
self.cellHeights.append(cell.frame.size.height)
}
I need to check whether an element at a specified index exists. However the above code does not work, I get the build error:
Conditional downcast from CGFloat to CGFloat always succeeds
I also tried with:
if let height = self.cellHeights[index] {}
but this also failed:
Bound value in a conditional binding must be of Optional type
Any ideas whats wrong?