kenechi learns code https://kenechilearnscode.com Tue, 01 Nov 2016 11:54:40 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.8 https://i0.wp.com/kenechilearnscode.com/wp-content/uploads/2016/09/VUl_aWWn.jpg?fit=32%2C32 kenechi learns code https://kenechilearnscode.com 32 32 Playgrounds are Cool! https://kenechilearnscode.com/index.php/2016/11/01/playground-are-cool/ https://kenechilearnscode.com/index.php/2016/11/01/playground-are-cool/#respond Tue, 01 Nov 2016 11:53:05 +0000 https://kenechilearnscode.com/?p=31 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.

]]>
https://kenechilearnscode.com/index.php/2016/11/01/playground-are-cool/feed/ 0
Hey Siri! – Siri Intents Extension Tutorial Part I (iOS 10, Swift 3.0) https://kenechilearnscode.com/index.php/2016/10/29/hey-siri-siri-intents-extension-tutorial-part-i/ https://kenechilearnscode.com/index.php/2016/10/29/hey-siri-siri-intents-extension-tutorial-part-i/#respond Sat, 29 Oct 2016 14:26:46 +0000 https://kenechilearnscode.com/?p=27 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!

]]>
https://kenechilearnscode.com/index.php/2016/10/29/hey-siri-siri-intents-extension-tutorial-part-i/feed/ 0
User Notifications Tutorial (iOS 10, Swift 3.0) https://kenechilearnscode.com/index.php/2016/09/18/user-notifications-tutorial-ios-10-swift-3-0/ https://kenechilearnscode.com/index.php/2016/09/18/user-notifications-tutorial-ios-10-swift-3-0/#respond Sun, 18 Sep 2016 16:10:44 +0000 https://kenechilearnscode.com/?p=15 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 – https://github.com/kenechilearnscode/UserNotificationsTutorial (Part I)

https://github.com/kenechilearnscode/UserNotificationsTutorial/tree/Part-II (Part II)

Part 1:

Part 2:

UserNotifications Framework Reference (recommended read)

]]>
https://kenechilearnscode.com/index.php/2016/09/18/user-notifications-tutorial-ios-10-swift-3-0/feed/ 0