Hi I am somewhat new to iOS and swift. I recently switched to swift 2.3 and now I am getting this error
Use of undeclared type 'IndexPath'
for this method
override func collectionView(collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
Any Ideas??
The function parameter should be NSIndexPath
not IndexPath
. Xcode 8+ uses the documentation and code completion for Swift 3.0
.
Swift 2.3 syntax:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
Swift 3.0 syntax:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath)
Yup! It's wrong in the Apple documentation. Not sure why they don't just fix it
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.