Reader small image

You're reading from  Apple Watch App Development

Product typeBook
Published inApr 2016
Reading LevelIntermediate
Publisher
ISBN-139781785886362
Edition1st Edition
Languages
Right arrow
Author (1)
Steven F. Daniel
Steven F. Daniel
author image
Steven F. Daniel

Steven F. Daniel is the CEO and founder of GENIESOFT STUDIOS, a software development company based in Melbourne, Victoria, that focuses primarily on developing games and business applications for the iOS, Android, and Mac OS X platforms. He is an experienced software engineer with more than 17 years' experience and is extremely passionate about making people employable by helping them use their existing skills in iOS, Android, and Xamarin to get the job done. He is a member of the SQL Server Special Interest Group (SQLSIG), CocoaHeads, and the Java Community. He was the co-founder and Chief Technology Officer (CTO) at SoftMpire Pty Ltd., a company focused primarily on developing business applications for the iOS and Android platforms.
Read more about Steven F. Daniel

Right arrow

Chapter 3. Exploring WatchKit Controls

In this chapter, you will learn how to build a simple guessing game application for Apple Watch that will allow the watch to randomly generate a number and have the user try and guess the number. You will learn how to use Interface Builder to create the visual user interface for our application using some of the controls that come as part of the WatchKit platform.

You will learn how to customize each of the control objects by interrogating their properties using Attributes Inspector and then learn how to create connections with each of our controls using Outlets so that we can access their getters and setters through code. You will also learn how to create Actions to control objects, which are basically events that are called when a user performs an action.

To end the chapter, you will learn how to compile, build, and run the Guessing Game application using the watchOS simulator so that you can test the app and ensure that everything is working correctly...

Building the Guessing Game application


In this section, we will take a look at how we can go about designing our user interface for our Guessing Game application. We will begin by developing the WatchKit and iOS app portion of our application.

Before we can proceed, we need to create our GuessingGame project. It is very simple to create this using Xcode. Simply follow the steps listed here:

  1. Launch Xcode from the /Applications folder.

  2. Choose Create a new Xcode project or go to File | New Project:

  3. Select the iOS App with WatchKit App option from the list of available templates under the watchOS section, as shown in the following screenshot:

  4. Click on the Next button to proceed to the next step in the wizard.

  5. Next, enter GuessingGame as the name for your project.

  6. Select Swift in the Language drop-down menu.

  7. Select iPhone in the Devices drop-down menu.

  8. Ensure that the Include Notification Scene checkbox is selected.

  9. Click on the Next button to proceed to the next step in the wizard.

    Note

    The Organization...

Summary


In this chapter, we introduced to some of the WatchKit user interface element controls that come packaged with the WatchKit platform. You learned how to work with Interface Builder and noted how easy it was to design our user interface for our Guessing Game application. You learned how to use and customize the WKInterfaceSlider, WKInterfaceLabel, and WKInterfaceButton control properties.

Next, you learned about Outlets and how we can connect and bind them up to control objects within the Interface Builder canvas. We then moved on to learning about creating Action events to our control elements that will be able to respond to user actions when tapped. In our final steps, we looked at how to write the code required for our Guessing Game application to respond to actions performed by the user and provide visual feedback to the user using the WKInterfaceLabel control.

In the next chapter, we will explore the WatchKit framework more and discuss the new layout system when placing controls...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Apple Watch App Development
Published in: Apr 2016Publisher: ISBN-13: 9781785886362
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.
undefined
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

Author (1)

author image
Steven F. Daniel

Steven F. Daniel is the CEO and founder of GENIESOFT STUDIOS, a software development company based in Melbourne, Victoria, that focuses primarily on developing games and business applications for the iOS, Android, and Mac OS X platforms. He is an experienced software engineer with more than 17 years' experience and is extremely passionate about making people employable by helping them use their existing skills in iOS, Android, and Xamarin to get the job done. He is a member of the SQL Server Special Interest Group (SQLSIG), CocoaHeads, and the Java Community. He was the co-founder and Chief Technology Officer (CTO) at SoftMpire Pty Ltd., a company focused primarily on developing business applications for the iOS and Android platforms.
Read more about Steven F. Daniel