Category: WatchKit
-
Tip: Deep Dive into Any? Dictionaries
In many factory methods, you’ll find parameters with type Any? like this: userInfo parameters in iOS and context in watchOS use these. You can place anything there, but most often, you’ll use a dictionary of type [String:Any]. This is a great way of moving multiple values from one method to another without making a class…
-
Why do we need Delegates in iOS and WatchOS?
About two years ago someone asked me a very good question: Why do we need delegates for UIViewControllers? He thought Swift made things easier, but this delegate stuff seems very complicated. Shouldn’t we be able to send a message or initializer between classes? When I first learned iOS, I’ll admit it took me months to…
-
Make a WatchOS 3 Haptic Catalog with a Picker
How does the Apple Watch communicate to the user when they are not looking at the watch face? That is done with haptics. Haptics are sounds and taps letting the user know something is happening. In this lesson, I’ll explain to you how to use haptics in Watch OS applications by creating a catalog of all the haptics…
-
Adding iOS Local Notifications in Swift
The word notification gets a bit abused in the world of mobile development, especially in the world of Apple development. Notifications could mean internal notifications, where classes use observers to watch unrelated code. When a notification appears, the observer code executes special code for that event. Another type of notification notifies a user that something…
-
Tables and Scroll Views in WatchOS2
One of the most powerful and important controls on both wearable and mobile devices are table views. Table views come in two flavors: static and dynamic. Dynamic table views read data from a collection type and displays it. Static tables allow for a vertical scroll view with a set of controls. Static table views are…
-
How to Use Watch Timers and NSTimers in WatchOS2 and Swift
There’s a legacy from WatchOS1 which is not only frustrating but deceptive. While one would think that a watch would have easy to use built in timers, that is far from the case. WatchOS2 changed this situation slightly, but still makes timekeeping not as easy as one would think. There is a timer in WatchKit,…