List of items in a playground
In this chapter, we will get familiar with different collections of data. They are pretty useful for storing data in memory and to work with, but in many cases we should present a collection of the data to the user. In the previous chapter, we discussed some nice UI iOS components which can be used in our app. Now, we will learn how to present an array of values in a simple collection view. To show this, we will use a playground and do some experiments with the view.
UICollectionView
UICollectionView
is a visual component which presents ordered collections of data items using custom layouts. By default, iOS comes with one pretty robust layout—UICollectionViewFlowLayout
which orders all items in a grid. But the underlying hierarchy gives an abstract class—UICollectionViewLayout
which could be used as a basis for new layouts. We will discuss that later in this section. Now, let's create a basic UICollectionView
:
- Create an empty playground.
- Add the following imports...