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

The Interface Controllers


With the PBLocationManager in place, we have done the heavy lifting of the app. The interface controllers are very slim in design and simple in implementation.

Create the InterfaceController class

Select the InterfaceController.swift file that was created as part of the Xcode template and replace all of the code in it (including the import statement) with the following:

Import WatchKit

class InterfaceController: WKInterfaceController, PBLocationManagerDelegate {

    var locationManager: PBLocationManager! //1

    override func awakeWithContext(context: AnyObject?) {
        super.awakeWithContext(context)
        locationManager = PBLocationManager(delegate: self) //2
        locationManager.requestLocation() //3
    }

    func handleNewLocation(newLocation: CLLocation) { //3
        print(newLocation)
    }

    func handleLocationFailure(error: NSError) { //4
        print(error)
    }

}

What we are doing here is writing the bare minimum code necessary to test...

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}