knuspermagier.de

Der privateste Blog von Philipp.
Hallo! Ich habe gerade freie Kapazitäten und suche Projekte mit PHP / Laravel / Vue.js / React / etc. Wenn ihr was habt, schreibt mir gerne

Trying WatchKit (1)

Yes, I’m a bit late to the game but last weekend I decided to finally get in touch with WatchKit. My first project will be developing an App for Better, the (still unreleased) spendings tracking app I talked about multiple times.

Goal

My goal is to have a quicker way to add spendings. Open the app, choose the category and the amount, done. Also I want to have a glance that shows the total amount of the current month.

First steps

Adding a WatchKit component to your app is quite easy as Xcode does provide a nice template. I immediately switched to Interfacebuilder and added a WKTableView for the categories to the first controller.

I added some mock data to the generated InterfaceController.m and ran the App for the first time. Success! That went easier than expected.

My next challenge was to find out how to get the data flowing between the iPhone and the Watch. At first I tried to get MMWormhole to work. I followed the instructions and created App Groups and Entitlements and stuff, but it still wasn’t doing anything.

watch1.png

One roundtrip to StackOverflow later I discovered [WKInterfaceController openParentApplication:reply:] which seemed to be good enough for my use case. Unfortunately it did not work either.

Well, the problem was that the data that should be transferred must comply to the NSCopying protocol. Of course. How could I forget this?

Very unlike me I directly used the method that gets some models from Core Data to produce the data that’s transferred to the app. Usually I would work with some dummy data… that would have saved some time in this case.

Buttons, Buttons, Buttons

First controller done, next up: The controller to add a new spending. For the first try I settled with a pretty standard numpad button layout. The buttons on the lock screen are not much bigger, so I think it should work…

watch2.png

If it gets to tedious I’ll add another step with recent spendings that can be added again. I use the feature quite often in the iPhone app.

But at first I have to find time to implement this, so stay tuned for the next post!

Du suchst nach mehr? Ältere Posts von 2018 bis 2013 befinden sich im Archiv , viel Spaß!