Interface Controllers
Now the SessionManager
class is ready to test. To do this, we simply need to create the sharedInstance
in the InterfaceController
class which we will now implement.
In the project navigator, select InterfaceController.swift
, and add the following code to the InterfaceController
class's awakeWithContext
method:
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
requestWeatherData()
}
The compiler will complain about not knowing any such method, so we'll fix that now.
Add the following function to the InterfaceController
class:
func requestWeatherData() { //1 WeatherSessionManager.sharedInstance.fetchWeatherData() { //2 (data: NSData?, response: NSURLResponse?, taskError: NSError?) -> Void in if taskError == nil { //3 do { let jsonData = try NSJSONSerialization.JSONObjectWithData( data!, options...