Blocks save the day

I’m consistently amazed how useful blocks are in Objective-C. So much so that I’ll be attempting to document useful ways that blocks can make your life easier as an iOS developer. Here’s the first of (hopefully) many posts of its kind.

Take this code

- (void)viewDidAppear:(BOOL)animated {
{
    UIView *viewToAnimate = ...
    [self performSelector:@selector(animateIt:) withObject:viewToAnimate afterDelay:1.0f];
}

-(void)animateIt:(id)sender 
{
    // animate viewToAnimate
}

It seems like this could be better by having the animation code where you have your selector delay setup. Well guess what? Blocks to the rescue!

@implementation NSObject (PerformBlockAfterDelay)

- (void)performBlock:(void (^)(void))block 
          afterDelay:(NSTimeInterval)delay 
{
    block = [[block copy] autorelease];
    [self performSelector:@selector(fireBlockAfterDelay:) 
               withObject:block 
               afterDelay:delay];
}

- (void)fireBlockAfterDelay:(void (^)(void))block 
{
    block();
}

@end

This snippet is using category that you can #import into your class. Using this in practice you get this.

- (void)viewDidAppear:(BOOL)animated {
{
    UIView *viewToAnimate = ...
    [self performBlock:^void() {
        // animate viewToAnimate
    } afterDelay:1.0f];
}

Credit goes out to this StackOverflow thread for the tip.

More

Notes on Rework

Rework has been on my “things to read” list since it was published over a year and a half ago. I was surprised when I came across a copy at my local library and couldn’t pass it up. Rework is a book that is entirely made up of material from the signal vs noise blog from the founders of 37 signals. It contains quite a bit of unconventional advice about business related topics. It was quite the fast read coming in at 288 pages with chapters only being a few pages long. They actually point out that the original draft was double the size but they chose to weed out the parts that distracted from the flow of each of the chapters. Or in their own words.. build half a product, not a half-assed product.

What follows are some of the more memorable take aways from this book..


By learning from other people’s mistakes you’ll be discouraged from trying to figure out a better, more successful solution to the problem at hand.

Draw a line in the sand. When it comes to developing software you will inevitably get requests from your audience for new features and things that you should be doing differently. Keep in mind that these are simply suggestions and even though they may be valid suggestions that sometimes its not essential to be so accommodating and determine what the primary purpose of your application is.

Just because your competition is adding feature X doesn’t mean that you should be chasing them to stay on par with their features. Your software is unique and doing something extremely well says more than doing many different things that are half-assed.

Make tiny decisions. Get into the rhythm of making decisions rather than postponing for the perfect solution. If you don’t make the smaller decisions they’ll eventually pile up and be harder to tackle until they get tossed aside and never resolved.

Don’t be afraid to launch your product sooner than when you’re comfortable with, launching in an iterative approach lets you release the essentials first instead of spending the time on extras that aren’t necessary for day one. Quick wins like these are important since momentum fuels motivation.

Teaching your customers can be just as effective if not more so than marketing to them. By doing so you help your customers improve upon their skills and is a way of gaining their loyalty. Think of how a cooking show teaches their audience to become better at preparing meals thus more inclined to buy products that they recommend. Or how your local home improvement store holds do-it-yourself clinics throughout the year.

Things like answering the phones, your software’s error messages, or the after dinner mint are all forms of marketing. Everyone should be involved.

Own your bad news by being the first to tell your customers when things go wrong. Better this than having it spread to other sources and become construed into something it isn’t.

Be close to your customers. By doing this you see first hand what others are saying about your products. Just like how the bad news can become twisted around and unreliable, feedback from your customers can become the same way.

Sound like you. Avoid things like buzzwords and corporate speak, also write to be read, don’t write just to write. Write like its just for one person so that you avoid generalities and awkwardness.

Inspiration is perishable, so don’t put it off. Set aside time in the near future and dive in and you’ll find that you can get much more done when you’re inspired then when you get around to doing it later on down the road.

More

Cocoaconf 2011 Recap

Cocoaconf Logo

Cocoaconf actually took me by surprise as I just happened to hear about it from a tweet within a month of it taking place. It’s pretty rare to find developer events of this size so close by Detroit so I had to jump on the opportunity. Who would’ve thought that I would get so much out of spending a few days in Dublin, Ohio?

Cocoaconf is a brand new conference that’s geared towards a technical audience (eg: no vendors were present). There were sessions for many skill levels and even an all day “soup to nuts” workshop that created an iPhone app from scratch using many of the Cocoa API’s. The sessions that I found most helpful were ones that I don’t normally see too much coverage of like UIAutomation with tuneup_js as well as unit testing with ghunit and ocmock. I would say that the session that surprised me the most was on NSURLConnection and the different networking protocols and technologies that are present in Cocoa. Immediately I could see the benefit of things like Bonjour discovery and the AFNetworking library.

One session that I thought was unique was the “We Made An App For That” talks where attendees had the opportunity to talk about their experiences in building their app and give a demonstration of how their apps function. The apps ranged from one that had just been released within the last month and even one that had sold thirty thousand copies!

To help give the speakers feedback there were cocoa bucks being rewarded for those folks who filled out the questioners. These cocoa bucks were then entered in a drawing to win prizes at the end. This was clearly an important part of the conference as they were being handed out at all of the doors, and from the looks of things they had a good amount of them turned in. I actually didn’t realize at the time but quite a few of the books that were being given out were written by the speakers at Cocoaconf. This goes to show you the quality that was put into their debut event and from the sound of things it’s only going to be getting better.

More

So whats new?


It’s a good feeling knowing that you’re getting things done. Doing all of those things that you’ve maybe thought about getting around to and then lost the sticky note that it was written down on. I’ve even been able to squeeze in a blog post, now that’s some serious GTD if you ask me!

Where do I begin? Over the last month or so I’ve been rather busy with a few things, in no particular order..

And last but not least we announced our new Quicken Loans mobile app.

More