Chan Jing Hong
Chan Jing Hong

Reputation: 2461

Unable to initialize UICollectionView in Xcode Playgrounds

I tried to initialize a UICollectionView:

import UIKit
import PlaygroundSupport

let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))

But all I'm getting is

error: Execution is interrupted, reason: signal SIGBART

Upvotes: 2

Views: 421

Answers (1)

Francesco Deliro
Francesco Deliro

Reputation: 3939

To initialize a UICollectionView use init(frame: CGRect, collectionViewLayout: UICollectionViewLayout), check Apple Doc:

let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 100, height: 100), collectionViewLayout: UICollectionViewFlowLayout())

Upvotes: 9

Related Questions