Недавно я преобразовал свой код в Swift 3.0. Теперь мои методы представления данных в виде коллекции и таблицы видят IndexPath
вместо NSIndexPath
в своей сигнатуре метода. Но все же внутри определения метода это тип casting IndexPath для NSIndexPath. то есть.
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
.