2016-10-17 5 views
0

こんにちは、私はiOSと迅速に新しいです。私は最近、SWIFT 2.3に切り替え、今、私はこの方法Swift 2.3 CollectionViewのIndexPathエラー

override func collectionView(collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell 

任意のアイデアはこのエラー

Use of undeclared type 'IndexPath' 

を取得しています?

+0

@EricAya私はそれを試みました。 – xazb

+2

関数は次のようにする必要があります。collectionView(collectionView:UICollectionView、cellForItemAtIndexPath indexPath:NSIndexPath) - > UICollectionViewCell –

+0

swift 2.3とswift 3.0の構文が混乱しているようです。 – xazb

答えて

4

関数パラメータは、NSIndexPathではなく、IndexPathである必要があります。 Xcode 8+は、Swift 3.0のドキュメントとコード補完を使用しています。 2.3

スウィフト構文: 3.0

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell 

スウィフト構文:

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) 
+0

@Sanjeetvermaは完全な方法がこのように見えることは間違いありませんでした。 'コレクションビュー(collectionView:UICollectionView、cellForItemAtIndexPath indexPath:NSIndexPath) - > UICollectionViewCell' – xazb

0

うん! Appleのマニュアルでは間違っています。なぜ彼らはそれを修正していないのか分かりません

関連する問題