100 Days of Code Day 8 - Coding the Moodsmitten Today Extension

|

Yes, It’s past 3am now and officially Tuesday, but I’ve been hacking away on Moodsmitten 1.1. At last, I have a Today Extension!

In an unexpanded view, the widget displays the topmost thought record, and if you tap "Show More," it shows the others. I implemented the updating the mood rating for the day with the down and up arrow buttons. Eventually, there will be OpenURLs to the main app to add a new thought record and view specific thought records.

Store Migration

In order to make a useful Today Extension, I had to figure out how to share my Core Data classes. As I planned out yesterday, I knew I had to move the SQLite store to a shared location. This is the first time I’ve had to make a migration, but it wasn’t as scary as I thought. In a nutshell, on launch I check if the store exists in the old location, and if it does I migrate to the new location and delete it. I still have to extensively test the migration, toggling through the 1st and 2nd versions of my app in order to see that everything went smoothly. After all, valuable data is on the line, and I have to get this right the first time.

Refreshing the Main App’s UI

Because it sped up development and simplified my code, I used a separate instance of my Core Data stack to update information from the Today Extension. While it’s easy to refresh the extension by making a fetch request for the current day, it’s a bit less straight-forward to update the main app’s UI after the widget makes a change. In the end, I figured out that Darwin events and CFNotificationCenter (which is very similar to NSNotificationCenter) did the trick.

Design

I’m going to have to talk to people, read the HIG, and think about the UI of the Today Extension. Right now I’m not happy with it.

Tomorrow…errr…Today

Whether or not I actually sleep, day 9 of these one hundred days will be spent making urls in Moodsmitten so my extension can send the user off to different places.

Support Moodsmitten

Did I mention that Moodsmitten 1.0 is already on the App Store? It’s free-to-download with a $4.99 in-app purchase to unlock all functionality. If you’re into CBT or need a place to challenge your automatic thoughts, look no further!

Did you like this post? Are you smitten for Soundsmitten? Click the "Tweet" link below to retweet my post. It keeps my livelihood afloat, brightens my day, and I'm always eternally grateful. Thanks for your help!