Oct 02

One of the great advantages of the iPhone platform is that it’s a single target to develop for. It doesn’t suffer from the “write once, test everywhere” syndrome of J2ME. But with 2.0, 2.1 and future firmware releases, not to mention rumored tablets and other new touch products, this will change.

The other day I managed to write an application that worked on 2.0 but not 2.1 devices. After some investigation I found that the root cause was a subtle change Apple made in 2.1 without any notification in release notes or in the SDK documentation.

Consider this very common snippet of code:

NSData *webData = [NSData dataWithContentsOfURL:url];

If the url in the above example refers to a file that is gzipped, e.g. www.myserver.com/file.gz, NSData will now (in 2.1) unzip the data automagically. So if your code was expecting to receive a representation of the compressed file, it will now break.

Most browsers will to the gzip/gunzip automagically when a web server sends compressed content. This is done to save bandwidth, improve download speed, and is generally a Good Thing. When the same “feature” is implemented in the SDK and you are not given any control over the behavior, that’s a Bad Thing.

The moral of this story is that you need to test all your code on both 2.0 and 2.1 devices.
 

written by Nick \\ tags: