Chapter 10. This Is Only the Beginning

That was nine chapters of pretty intense material. You will probably (and quite rightly) be proud of your achievements so far. From now on, everything you learn will be built upon a solid foundation that has already enabled you to get an app submitted to Apple's App Store.

This chapter is concerned with the many possible avenues that are available to you to deepen and broaden your programming skills, to make the most of the valuable time you spend coding, and to give your app the best possible chance of achieving its potential once it has been released to the world at large.

In this final chapter we will cover the following topics:

  • Advanced custom navigation
  • Onboarding
  • Using the Code Snippets Library
  • Post release improvement and maintenance
  • Analytics frameworks
  • Program design and programming paradigms
  • Using the command line
  • Using Xcode's tools
  • Git and version control
  • Useful utility apps and essential resources
  • Open sourcing

Using animation to the fullest

We have seen how animation can be used to produce a more vibrant, engaging user interface, but this is only scratching the surface of what can be done by animating the changes in the property values of UI elements. Despite the relatively modest number of properties we can animate, with a little imagination we can create effects that are simple, but which fundamentally alter the way we engage with the Apple Watch.

We have already seen in Chapter 2, Hello Watch, how simple it is to overcome the lack of a completion handler in calls to WKInterfaceController class's animateWithDuration method by extending the class with a method that chains together sequentially an arbitrary number of animation blocks. By combining concurrent and sequential animations we have at our disposal an unlimited number of ways to add complex (although often subtle) movement to our interface without having to deal with masses of complex code. The key here is to think about what we can do with the techniques at our disposal, rather than to search for new techniques or third party libraries (or to not try in the first place).

Advanced custom navigation

Of course, animations don't have to be subtle. If we consider that the watch screen is fundamentally an object that shares many characteristics with WKInterfaceGroup itself, we begin to approach the idea that, conversely, a WKInterfaceGroup object can be considered to be a container for a whole screen of user interface elements. Such a screen is not subject to the limitations of the top level WKInterfaceControllerview, and by swapping between several such UI groups, we can effectively extend our navigation palette far beyond that which is offered by vanilla WatchKit.

Using the techniques that we have covered in many of the previous chapters, you are able to add two or more WKInterfaceGroup objects to the InterfaceController in Interface Builder. Put them both in an outer WKInterfaceGroup, making sure to set its Layout property to Horizontal. This group will contain everything in the UI, as illustrated here:

Advanced custom navigation

By setting each of these groups, let's call them UI-Groups, to be the size of the whole screen, that is, by setting both their Height and Width properties to Relative To Container (with the default vale, which is 1.0), we can change screens using any of the size and layout properties of those objects.

In the GitHub repository, there is a small Xcode project called AdvancedNavigation, which will illustrate a very simple implementation of this idea:

https://github.com/codingTheHole/BuildingAppleWatchProjectsBook

All this project does (as you will see if you download it) is change the widths of two side-by-side UI-Groups. The one that should be visible has a RelativeWidth value of 1.0 and the other, rather than being hidden through its Hidden property, has a RelativeWidth value of 0.0. The values of these properties are then swapped to effect a change in which UI-Group is visible; by wrapping this in an animation closure, we create an interesting transition from one screen to another. In the example code in the GitHub repository, each UI-Group contains nothing more than a button to start (or revert) the change of screen along with an image view to make things slightly clearer to follow, but in your app such a UI-Group could contain further buttons, labels, tables, even the WKInterfaceMap objects, as well as further WKInterfaceGroup objects. There is no limit to the flexibility of an interface constructed in this manner.

Onboarding

One popular trend in UI design, and one that is to be widely applauded in this author's opinion, is to include a so-called onboarding experience in an app, by which the user is guided through the essentials of an app's UI, usually through a sequence of static screens. Once the guided tour is over, the user is familiar with a number of features that the app has to offer, as well as a good idea of how to use them. The onboarding sequence is never seen again.

This is an excellent way to introduce your users to your app.

You might think, hey, that's a lot of resources to include in my tiny watchOS bundle for a feature that will only be used once, but in fact the code that defines a storyboard is no more than a modest amount of text in XML format. For example, here is about half of the storyboard from the project from Chapter 2, Hello Watch:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="8173.3" systemVersion="14F27" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="AgC-eL-Hgc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8142"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="8089"/>
</dependencies>
<scenes>
<!--Interface Controller-->
<scene sceneID="aou-V4-d1y">
<objects>
... more code here ...
</document>

Not much, is it? So creating a series of Group objects is an inexpensive way to add value to your app (provided that you don't pack them full of images and movies, of course) and represents a perfectly viable way of creating a pleasing, helpful, and ultimately rewarding introduction to the user's experience with it.

Once the sequence has been viewed by the user, simply add a Bool value to the NSUserDefaults.standardUserDefaults() dictionary, indicating that this is the case. Each time the app launches, it checks whether this flag has been set to true, and if it has, it skips the intro.

These are just two of the ways that you can leverage WatchKit's simple but powerful animation features to create features that would normally be associated with the larger devices without using up a ton of memory and writing horrifically complex code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.187.79