Now, we are going to display some pictures that were taken on the chosen city. As you know, we can use a table view for it. But, for this scenario, Apple has something more appropriate called the collection view.
Create a new file in the ViewControllers
group called PicturesViewController.swift
. Start by creating a class that inherits from UICollectionViewController
:
import UIKit class PicturesViewController: UICollectionViewController {
This class will need a special nested class to store the pictures' information, as we need to keep the URL, the title, the pictures ID, and the local path where it is stored:
private class PhotoInfo { var title:String! var url:String! var localPath:String! var id:String! }
As properties, we just need the cityInfo and the array of PhotoInfo:
var cityInfo:CityInfo! private var photos = [PhotoInfo]()
After this, we can initialize the array by requesting Flickr for a list of pictures and then...