Making the web easier in Cocoa
Having come back to Cocoa in this last year from having spent a few years writing Python, I’ve taken a much more holistic approach to writing Mac and iPhone code. Where as before, having come from being a C hacker, I was writing lots of low level code myself (and to be fair, six or seven years ago, or whenever it was I wrote things like osx2x, there wasn’t a huge alternative) now I find myself looking around to see what libraries exist to help me get on with the interesting bits. This is one of the really great things about Python – it’s library support, both in terms of the standard libraries and what’s out there in the internets, is fantastic, and now the same applies for Objective C.
So, I thought I should post about a couple of the more useful ones I’ve been using recently. As a full on webhead these days, a lot of the client code I write is to interact with web services (as Nik Fletcher said recently, it seems like writing a Twitter client is the new “Hello, World!”). I’ve been using two libraries to help me here: one to make the requests, and the second to help decode them.
First up is None from All-Seeing Interactive. This library makes it really easy to start firing off requests to web services without having to worry too much about the code. It comes with very good documentation with examples, and has lots of advanced stuff I’m yet to take advantage of, such as automatically updating progress indicators in your UI, talking to S3, etc. I’ve been playing with the form request functionality, which makes it very easy to do an authenticated POST of data to a web service as part of an API. If you’re talking to the web and you’re using Cocoa’s standard libraries for network interactions, you really should give this a look.
The second recommendation is json-framework. JSON is becoming a fairly common marshalling language for web APIs to talk – it’s less verbose than XML, it’s still human readable, and it’s easy to code with. The JSON framework simply adds categories to NSString to generate NSArray or NSDictionary objects from strings containing JSON, and to NSArray and NSDictionary to generate an NSString containing the JSON encoded data. Very easy to use, and I’ve used this one lots with no issues.
There you have it, two very useful libraries that work well on both Mac and iPhone, that I highly recommend if you’re doing any web API work.
- Next: The computer for the rest of us
- Previous: Getting into eBooks
- Tags: Geek