DZone API and iPhone app

As I already mentioned, I am currently getting my hands dirty with Objective-C and iPhone application development.

The biggest problem with getting started was that I had no idea what application I could write for that device that could become somewhat usable. As I am a passionate tech reader, I consume a lot of articles posted on DZone. Usually I use a feed reader like NetNewsWire for that, which works very well for my MacBook but is nearly useless on the iPhone, because the DZone site is not very mobile friendly…

Problems

Since there was no DZone iPhone application on the marked I started working on it. Parsing DZone feeds was easy, even though the buildin XML support on iOS sucks. There were some nice libraries that made my life easier.

No deeplink

The DZone RSS feed does not provide a deeplink to the actual linked article, so one would still land on the DZone page… Since DZone does not provide an API currently, I started working on my own Rails application hosted on Heroku. Spidering the RSS, calling the page and extracting the link to the article is fragile, but it works (currently).

No voting

One of my goals was to let the iPhone user vote for the article while reading it. The lack of an API forced me to do some more fragile login and posting stuff to the DZone page, but it works too (currently)!

You can read more about the API I created on the actual page.

iPhone app

The first version of the “dzone mobile” app has passed the iTunes store review process and is available through the app store. A version with some minor bugfixes is currently beeing reviewed. Have a look at updates and documentation here or here.

voting

You have got to provide your DZone login credentials if you want to use the voting feature. Go to the iPhone Settings > DZone and add your username and password. I want you to know that there is NO SSL, so your credentials will be submitted UNSECURE!

more Features

If you are interested in pushing this further, you can add bug reports or feature requests on GitHub.

screenshots

DZone iPhone sugar!

Using blocks in Objective-C

One of my pious intentions for the year 2010 is to start writing some application for the Mac. Apart from the hype about iPhone development, I think that starting out in that area is especially appealing, as it reduces the size of the API one has to learn. Getting to know the iOS libraries is a lot easier than handling the endless amount of Cocoa frameworks.

One thing that I discovered recently is the support of blocks, that has been introduced with OSX 10.6 and iOS 4.0.

the environment matters

Consuming 3rd party data from the web is kind of a pain, especially compared to how easy it is in Ruby. So I was pleased to find Seriously, a framework for async calls and JSON/XML parsing. The Seriously examples made use of blocks:

NSString *url = @"http://api.twitter.com/1/users/show.json?screen_name=probablycorey";

[Seriously get:url handler:^(id body, NSHTTPURLResponse *response, NSError *error) {
    if (error) {
        NSLog(@"Error: %@", error);
    }
    else {
        NSLog(@"Look, JSON is parsed into a dictionary!");
        NSLog(@"%@", [body objectForKey:@"profile_background_image_url"]);
    }
}];

Executing this example in my app code raised an error, that I could not easily understand:

"__NSConcreteGlobalBlock", referenced from: ___block_holder_tmp_1.1207 in DZoneController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

The problem was, that XCode set my execution environment to OSX 10.5 which does not have support for blocks. To fix this, one has to update the MACOSX_DEPLOYMENT_TARGET build variable.

Right Clicking on the XCode project in the “Groups & Files” view will bring up a context menu with “Get Info” (or pressing CMD+I while project is selected). The info pane has a “General” tab that lets you select the “Base SDK for All Configurations”, which I set that to iOS 4.0.
An other option is to search for “MACOSX_DEPLOYMENT_TARGET” in the “Build” tab and changing that value accordingly. Make sure “Show” is set to “All Settings”.

At least some Objective-C sugar!