kenechi learns code Tue, 01 Nov 2016 11:54:40 +0000 en-US hourly 1 kenechi learns code 32 32 Playgrounds are Cool! Tue, 01 Nov 2016 11:53:05 +0000 I have an enum with several different cases, each case with its own computed String variable for its title. Elsewhere in my app I needed all of these titles, but I didn’t want to go through and type each one out. This is the kind of thing that should be automated, but as far as I know you can’t automate writing of code in Xcode. Here’s where playground comes in. My enumeration cases have Ints as associated values. I wrote a short algorithm to get the titles of each enum case and add them to an array.

Then I simply copied this array back into my code and finished by adding an assertion that attempting to initialize this enum type with the count of the array should always give nil. This is great because it means that the array doesn’t have to be calculated on the fly. The only pitfall, is that if the order changes then the array would be wrong but for my purposes it’s irrelevant and there are many ways around this. The takeaway is that playgrounds can be used for automating the writing of code that would otherwise be tedious.

]]> 0
Hey Siri! – Siri Intents Extension Tutorial Part I (iOS 10, Swift 3.0) Sat, 29 Oct 2016 14:26:46 +0000 Sorry it’s taken me so long with this, I decided to build a workout app to implement the tutorial into and I ended up getting carried away. Better late than never though! So here’s part I of the tutorial. I show you how to get setup and how to implement Siri into an app (for workouts). The procedure is similar for other apps too, so hopefully this tutorial can also be useful in that sense. Let me know how you get on!

]]> 0
User Notifications Tutorial (iOS 10, Swift 3.0) Sun, 18 Sep 2016 16:10:44 +0000 This is a two part tutorial all about Apple’s new User Notification framework, to show you how to use rich, interactive local notifications in iOS 10. In part one I show you how to: request authorisation from the user to send them notifications, create and schedule a local user notification, handle the display of that notification in-app, add actions to the notification using notification categories. and react to the action the user selected.

Part two deals with adding attachments, modifying pending and delivered notifications & implementing a notification content extension.

Project on github – (Part I) (Part II)

Part 1:

Part 2:

UserNotifications Framework Reference (recommended read)

]]> 0