我正在尝试快速枚举所有集合视图单元格,但下面的实现给了我一个警告。
for cell in self.collectionView?.visibleCells() as [UICollectionViewCell] {
// Do Stuff
}
第一行出现以下错误:
后缀"?"的操作数应具有可选类型;类型为'(UICollectionView,cellForItemAtIndexPath:SIndexPath)->UICollectionViewCell的
我试过摆弄可选选项,并在Xcode 6 Beta 6中运行,但在"Beta 7"中无效
如何消除此错误?/写一个循环来遍历我的所有CollectionView单元格?
collectionView
属性现在是可选的UICollectionView?
,因此打开它:
for cell in self.collectionView!.visibleCells() as [UICollectionViewCell] { ... }