WishIHadThreeGuns
WishIHadThreeGuns

Reputation: 1469

visiblecells on a UICollectionView cannot invoke with no arguments

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

Answers (1)

inexcitus
inexcitus

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

Related Questions