Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Building Apple Watch Projects

You're reading from  Building Apple Watch Projects

Product type Book
Published in Feb 2016
Publisher Packt
ISBN-13 9781785887369
Pages 298 pages
Edition 1st Edition
Languages
Author (1):
Stuart Grimshaw Stuart Grimshaw
Profile icon Stuart Grimshaw

Table of Contents (17) Chapters

Building Apple Watch Projects
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Exploring the New Platform Hello Watch C-Quence – A Memory Game Expanding on C-Quence On Q – A Productivity App Watching the Weather Plot Buddy – All about Location Images, Animation, and Sound Wear It, Test It, Tweak It, Ship It This Is Only the Beginning Index

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...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}