Feel My Pain: NSXMLParser Problems Upgrading to the iPhone 3.0 SDK


I set out a couple of weeks ago to port the Killer Deals
application from the iPhone 2.2.1 SDK to 3.0. “No problem”, I thought; the
application doesn’t veer far from the standard APIs and controls, and it is a
relatively straightforward application, implementation-wise.

As I was making my updates (some minor method and property
name changes here and there), I stumbled upon a show stopper: The NSXMLParser
was no longer parsing my XML data. After scratching my head for a few hours, I
finally figured out the problem.

Dealing with JSON on iPhone


You can easily use the JSON (JavaScript Object Notation) data format in client-server communications when writing an iPhone app. This blog is not suggesting that JSON is a more superior format for data exchange than its counterparts such as XML. In fact, we have many projects that don’t use JSON. However, handling JSON is relatively straight forward in ObjectiveC.

Unfortunately, Apple iPhone SDK (as of this writing, the latest is iPhone 2.2.1) doesn’t come with a built-in JSON parser. But I found out a good one called json-framework. It is both a generator and a parser. As a generator, json-framework can create JSON data from an NSDictionary. As a parser, you can pass to json-framework an NSString that consists of JSON data and it will return a NSDictionary that encapsulates the parsed data.

Broadcasting Information: How to use the iPhone Notification Center


There are times when building an iPhone application that you
need to inform other parts of the program to do something, without regard to
what or where those parts are. The NSNotificationCenter (aka “notification
center”) is the way to go in these cases. Using notifications supports ‘loose
coupling’, which is a good thing in software design.

A notification center object provides a mechanism for
broadcasting information (“notifications”) within a task. An
NSNotificationCenter object is basically a notification dispatch table. For
those familiar with Windows programming, this pattern is similar to the Windows
Message Loop architecture.