Dumitru Rogojinaru Dumitru Rogojinaru - 25 days ago 28
iOS Question

swift 3 error : Argument labels '(_:)' do not match any available overloads on UICollectionViewLayout (Spinning wheel)

I am new to programming and I am trying to make a Circular effect to CollectionView, I have the following:

override func prepare()
{
super.prepare()

let centerX = collectionView!.contentOffset.x + (collectionView!.bounds.width / 2.0)
attributesList = (0..<collectionView!.numberOfItems(inSection: 0)).map { (i)
-> CircularLayoutAttributes in
// 1
let attributes = CircularLayoutAttributes(forCellWithIndexPath: IndexPath(forItem: i, inSection: 0))
attributes.size = self.itemSize
// 2
attributes.center = CGPoint(x: centerX, y: self.collectionView!.bounds.midY)
// 3
attributes.angle = self.anglePerItem*CGFloat(i)
return attributes
}


But I get the error : Argument labels '(_:)' do not match any available overloads, like on the picture, what am I doing wrong?

Pic1

Answer

The syntax has changed with Swift 3.

Use :

IndexPath(item: i, section: 0)

Comments