O'Reilly logo

Swift 2 By Example by Giordano Scalzo

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

Downloading the background image

Before moving on to downloading the actual forecast, we'll introduce the topic of networking downloading a geo-localized background image.

Searching in Flickr

To get an image, we'll use the API of Flickr, a famous image-hosting website, using a convenient Pod. First of all, we override the viewWillAppear function in PrettyWeatherApp so that a new image will be downloaded every time View Controller appears:

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)
    
    let lat:Double = 48.8567
    let lon:Double = 2.3508

    FlickrDatastore().retrieveImageAtLat(lat, lon: lon){ image in
        self.render(image)
    }
}

To implement the searching feature, we set a dummy value using the coordinates of Paris. Then, we create ...

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