A Watchdog Timer in GCD

A good way to help track down performance issues is through the use of a watchdog timer. They help you by pointing out the places in your code that are taking longer than they should. When the watchdog fires, it can do whatever action is appropriate for your application. I’m sure all iOS developers are aware of the more extreme watchdog timer that has existed since the beginning of iOS which would kill your application if it took too long to shut down. Our watchdog example will be far more benign :-) . (more…)



A Simple Job Queue With Grand Central Dispatch

In my last two posts, we talked about the basics of GCD and then delved into blocks. Now we’re going to start learning how to replace your old threading code with GCD. For this post, we’ll discuss how to create a simple sequential job queue using dispatch_async and friends. (more…)



Being a Blockhead

Last time I talked about asynchronous behavior via Grand Central Dispatch. One of the core features that makes this all possible is blocks. I thought I’d take a step back this time and just talk about blocks themselves and how they can be used by your code. (more…)



Threading is Dead. Long Live Threading!

I stated in a past post that threads are evil. I still stand by that statement. Adding threads to an application has historically been fraught with issues. Many stem from people not quite understanding all of the situations can arise, etc. Oh sure, you might know what a deadlock is, but do you know all the circumstances they can occur? How does one safely shut a thread down? Did the owning object go away? It’s not as simple as it seems in most cases.

But what if I could thread until the break of dawn and not have to worry as much about those situations? That’s exactly what Grand Central Dispatch gives you on Mac OS X, and now iOS — access to concurrency without nearly as much pain. (more…)



If Only I Could Write Like This

I ran across this quote from Oliver Reichenstein, and it embodies my thinking completely, though I’ve never been able to put it into such words.

We should use original tools to create iPad apps, not because Steve Jobs said so, but because these tools create products with flesh and bone, that is: an understanding of both the purpose, the potential and the limits of the iPad technology.

I’ve never been a fan of cross-platform frameworks, even though I’ve been involved in four to speak of to date (not always by choice). I like to think I’m pretty good at it at this point, but even the best of us ends up with mediocre platform support or performance because you’re trying to wedge your idea of the universe onto another. And we know from watching Fringe what happens when two universes meet.



I Love Xcode

A while back I wrote a post called “I hate Xcode”. These days I feel I need to post a revised statement based on my more recent experience with Xcode which can be summed up with: I Love Xcode. I guess this is much akin to Leonard Nimoy writing “I am not Spock” and later writing “I am Spock”. (more…)



My Journey To Tweetsville

Now that Tweetsville is out there, I thought I’d reflect a bit about where it came from and how it came to be.

When the app store opened, I downloaded several Twitter clients. Each was interesting in their own right, but I couldn’t use any of them because of one reason: the scrolling performance. I didn’t get why everyone’s scrolling was not as smooth as any of the built-in iPhone applications. For me, it made the apps frustrating to use, to the point that I just never used them.

(more…)



Tweetsville Update

Just wanted to post an update as to what was happening with Tweetsville, my iPhone Twitter app.

First, it’s been approved for sale! But I haven’t seen it show up and sadly I don’t have a link to it. Read on for why.

The main reason the app was delayed so long coming out is because I had been been trying to figure out exactly what to do with it. I might be in a situation soon that will actually prevent me from being able to maintain the application, so I wanted to see if I could find a good stewart for my baby. I’ve chosen to hand the application over to Tapulous, maker of Tap Tap Revenge, Twinkle, FriendBook, Fortune and Collage, with whom I have a good working relation.

I think this is going to be great for Tweetsville, as they have better resources at their disposal to help support and grow the application. I also think they have some technology which can help Tweetsville be even better than it is. At the same time, there’s some stuff I did for my app that I believe will benefit Tapulous.

There is no plan to have Twinkle and Tweetsville merge. They are to be separate applications with separate audiences. Twinkle is about locality and the Tapulous network, and Tweetsville is purely a Twitter application.

One of the advantages here for users is that there will be choice. There will ultimately be two versions of Tweetsville. The first will be a paid version currently slated for $3.99. The second will come a few weeks later and will be a free ad-supported version.

I’m confident this will move is the best thing for the Tweetsville app as well as users in the long run. You’ll get more choices and better support than I would have been able to provide on my own. I feel the app is in good hands, as I have a great working relationship with Tapulous (I’m actually doing a little work on Twinkle 1.3 these days too).

So look for it to appear in the App Store on Monday the 10th of November!

Update Actually the date is apparently going to be the 12th.



The Simple Beauty of clearColor

I’ve recently discovered the simple beauty of [UIColor clearColor] used for a background color. Previously I had been doing stuff like:

self.opaque = NO;
self.backgroundColor = nil;
self.clearsContextBeforeDrawing = YES;

But all I really needed to do was:

self.backgroundColor = [UIColor clearColor];

Same transparency, and I’m guessing (hoping?) that it might be a bit more efficient (unless of course, the innards look for clear color and effectively do what I used to).

Hey, even if it’s not more efficient, it’s certainly simpler to type and it seems to have the same effect!

Sadly, this is one thing I didn’t figure out on my own, but rather spied in some other sources, but I wanted to throw it out there for ‘all uh yous’.



Recursive Locks Will Kill You!

A while back, at Adobe, I ran into a most evil bug that took me hours to track down. In the end, it was the end results of people violating what (to me) are the three tenets of threaded programming. This post is what I ended up establishing as the thread safety guidelines for our project.

Before digging into it, I should say this: threads are evil. If you don’t believe this, then I believe you are made of living tissue over metal endoskeleton. You should endeavor to avoid threads at all cost. In most cases, timers are your best friend. Know them. Love them.

Of course, there are times when you need to use threads. I needed to add a few threaded operations to my iPhone application to make sure the UI stayed responsive. On the project at Adobe, we were doing thumbnailing of images, definitely something you don’t want happening on the main thread. (more…)