Chris Lundie’s Blog

I’m a software developer from Canada.
You can view my portfolio at www.Lundie.ca.

Jun 24

Apr 28

Apr 26

Responsive UI on the iPhone and iPad

Today I released an update to my iPhone & iPad app LinkDew. I think it does a decent job of keeping the UI responsive while doing some fairly intensive background operations.

The Problem

LinkDew is a Twitter client that displays photos uploaded by the people you follow. It uses Core Data to save information about your friends, their tweets and photos that were linked in the tweets. In the iPhone simulator, running on the computer’s Core 2 Duo processor, everything is so fast, you don’t notice any delay. Running on a real iPhone 3G, it can actually take two or three seconds to parse the results from the Twitter API, extract all the photo links, insert the Core Data objects representing the links and statuses, and various other operations. If this were done on the main thread, the UI would be blocked and everything would freeze up for a few moments. This is not good.

The Solution

I moved all of the heavy lifting to a background thread. The tricky part is that a Core Data context (NSManagedObjectContext) cannot be shared between two threads. So, the background thread needs to make its own context. This is straightforward, but what happens when the importing operation is done, and you save the context? Well, the context you are using on the main thread will not know anything about the changes that were made on the other context. What to do?

Core Data was designed with this in mind! You just need to register for this notification:

NSManagedObjectContextDidSaveNotification

When the “background” context sends this notification, I just call mergeChangesFromContextDidSaveNotification: on the “main” context, and make sure to do so on the main thread. Then everything syncs up and the UI is never blocked.


LinkDew is ready for Twitter’s transition to OAuth

Twitter recently reminded 3rd party developers that the “Basic Authentication” method will be removed in the coming weeks. This means that many web sites and applications, including iPhone apps, need to be updated in order to keep Twitter integration working. I expect that some old, abandoned apps in the App Store will stop working altogether.

My own LinkDew app was built for OAuth, so it will continue to work with no problem. I spent about two days writing my own code for OAuth and Twitter, because existing 3rd party code did not look very stable or well documented yet.

It appears that the popular MGTwitterEngine library is finally being updated. So, if you are writing your own app with Twitter integration, you may want to look into that instead of doing it yourself.


Apr 9

Mar 31

Mar 22

WhatVeggie iPhone app now available

I’m pleased to announce a new iPhone app called WhatVeggie. It contains all kinds of great reference material about fruits and vegetables. Just take it to the store and type in the 4-digit codes on the stickers.

http://www.lundie.ca/whatveggie/


Page 1 of 1