O'Reilly logo

Learning Swift by Andrew J Wagner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Populating our photo grid

Now that we are maintaining a list of photos, we need to display it in our collection view. A collection view is populated when you provide a data source to it that implements its UICollectionViewDataSource protocol. Probably, the most common thing to do is to let the view controller be the data source. We can do this by opening Main.storyboard and control dragging from the collection view to the view controller:

Populating our photo grid

After releasing the mouse, select dataSource from the menu. After that, all we need to do is implement the data source protocol. The two methods we need to implement are collectionView:numberOfItemsInSection: and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required