Я недавно преобразовал свой код в Swift 3.0. Мои методы представления данных в виде коллекций и табличного представления теперь содержат IndexPath
вместо NSIndexPath
в их сигнатуре метода. Но все же внутри определения метода это тип casting IndexPath для NSIndexPath. т.е.NSIndexPath и IndexPath в Swift 3.0
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{
let cell : NNAmenitiesOrFurnishingCollectionViewCell = self.amenitiesOrFurnishingCollectionView.dequeueReusableCell(withReuseIdentifier: "NNAmenitiesOrFurnishingCollectionViewCell", for: indexPath) as! NNAmenitiesOrFurnishingCollectionViewCell
cell.facilityImageName = self.facilityArray[(indexPath as NSIndexPath).row].imageName
cell.facilityLabelString = self.facilityArray[(indexPath as NSIndexPath).row].labelText
return cell
}
Может кто-нибудь сказать мне, почему indexPath
имеет тип отлиты в NSIndexPath
.