Reputation: 1469
The documentation is here: https://developer.apple.com/documentation/uikit/uicollectionview/1618056-visiblecells
But I cannot seem to use this: notesCollectionView.visibleCells() as! [NotesCollectionViewCell]
has an error: "Cannot invoke 'visibleCells' with no arguments"
How can I get only the visibleCells in a UICollectionView?
Upvotes: 0
Views: 138
Reputation: 2639
The visibleCells
is a variable, but you are using the function call syntax.
Removing the () should do the trick.
if let cells = notesCollectionView.visibleCells as? [NotesCollectionViewCell]
{
// Do your magic here.
}
Upvotes: 1