DEV Community

Discussion on: How do I create a UICollectionView with standard layout programmatically in Swift 4?

Collapse
 
recursivefaults profile image
Ryan Latta

I think you're two choices are going to be a classic version and the on you used. The classic one would look like this.

let myCollectionView: UICollectionView = UICollectionView()

I'm assuming there aren't required parameters.

Generally speaking I don't use closures for things when I can make it more explicit otherwise. I find they read poorly and depending on the language and situation you have to know that the closure executes on a seperate thread or execution context.

I've not used the closure based way before, so I can't speak to its long term usefulness. My first reaction to it is that I'd probably not use it unless I was doing something very complex that wrapping it up a function wouldn't cover.

Thread Thread
 
danpgomez profile image
Daniel P-G

Thank you so much!