Many people transfer data to and from web services to the iPhone via JSON. This is a much better way than using XML. Parsing XML on the iPhone just plain sucks. It's overly complicated and super confusing. Currently the YouVersion app, Bible, uses JSON to transfer everything back and forth from the server and it all works great.
So you're probably thinking, "So, great I'll just keep doing that." I did too until I went to one of the Apple iPhone Tech Talks. I learned a ton about how to optomize iPhone apps. One of the big things they hit on was using plists to transfer data back and forth instead of JSON or XML.
The huge benefit to using plists over JSON is that you don't have to parse them, they are 100% native. You can initialize an NSDictionary or NSArray with just one method.
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:plistURL];
NSArray *array = [NSArray arrayWithContentsOfURL:plistURL];
This is a super simple and easy way to do this. I would recommend using NSURLConnection to pull down your plist file to the temp directory and the run initWithContentsOfFile: instead of using the initWithContentsOfURL:. NSURLConnection provides some great added features, like being asynchronous and handeling HTTP auth, etc.
Feel free to grab the iPhone Plist Tutorial project source code on GitHub at http://github.com/samsoffes/iphone-plist. It's pretty straight forward. I tried to make it as simple as possible.
Now What?
You're probably thinking, "Great, so how do I get my data into a plist?" Well, all you have to do is google up a parser for your language. I started writing one for PHP because that is what I use. It takes a PHP array (associative or nonassociative) and converts it into a plist string. You can find it in the helpers folder in this repo.
Anyone Else Doing This?
I wish. It would be great if more web services offered a plist version of their API. In the new YouVersion API, we will be offering a plist format. Hopefully as the iPhone grows in popularity, this will become more and more common.
If you don't really have a choice, at least use JSON. Here is a great library for JSON that I currently use in Bible. The next version of Bible will be all plist using the new YouVersion API. I can't wait :)
Update: I have discovered since writing this that JSON is a better way to go. You can read my post about this. I no longer work on YouVersion, but I know they never released their API to the public (after I spent forever documenting it) and dropped plist support as well.
Update: This no longer works on 3.1.
Update: There are simpler instructions at http://9to5mac.com/iPhone-3G-tethering. I have heard rumors that this no longer works with iTunes 8.2. I personally haven't tried it in awhile.
So with iPhone 3.0 you can tether you computer to your iPhone, but not yet for some carriers. It's pretty dang sweet and works really well so let's do it early. It's actually pretty easy to get setup. I would write an app to automate it, but I'm sure Apple will release an update and break all of this soon, so follow my steps to get going.
I did this with iTunes 8.2 (23) on OS 10.6 (10A380) on AT&T with iPhone 3.0 (7A341), but I'm quite confident it works with iTunes 8.2 on Leopard and most carries (we'll look up a list later). You will need to make sure you are running the 3.0 firmware on your iPhone. I'll try to keep this pretty basic so you don't need technical knowledge. There are a lot of steps because I am very specific for people that are not familar with editing these kind of files. Don't be intimidated. It's pretty straight forward.
Quit iTunes and open up Terminal (/Applications/Utilities/Terminal.app)
Run the following command to enable carrier testing. We'll need this later
defaults write com.apple.iTunes carrier-testing -bool TRUE
Now we need to get the list of carriers. Run this command:
curl -s -L http://phobos.apple.com/version | grep -i carrier
That command will return a big list of ipcc files. Look for the one that ends in your carrier. If you have AT&T, it will be called ATT_US.ipcc. Copy that URL between the <string> tags.
Now type the last portion of the URL before .ipcc where it says YOUR CARRIER (mine would be ATT_US)
declare CARRIER="YOUR CARRIER"
So for AT&T, it would look like
declare CARRIER="ATT_US"
Type the following commands in Terminal. (Obviously paste the URL where it says.)
cd ~/Desktop
curl [PASTE URL HERE] > $CARRIER.zip
unzip $CARRIER.zip
rm -f $CARRIER.zip
open Payload
There should now be a folder on your desktop named Payload that just opened. (If there is not, start back at step one and carefully follow the instructions this time.)
Right click on the .bundle file in that folder and choose Show Package Contents. We're going to edit a few files in here. You will need to have the developer tools installed to get Apple's Property List Editor utility. If you do not have these tools, go to http://developer.apple.com/mac, sign up for an account, download Xcode, and install it. Once you do this, it will install Property List Editor in /Developer/Applications/Utilities/Property List Editor.app.
Right click Info.plist, choose Open With, then choose Property List Editor.
Once the Property List Editor is open, choose Show Raw Key/Values from the View menu in the menubar. The Property List Editor is pretty straight forward so don't be scared :)
Change CFBundleVersion to 5.0. Now save and close Info.plist.
Now open version.plist with Property List Editor, change CFBundleVersion to 5.0, save and close version.plist.
Now for the fun one :) Open carrier.plist with Property List Editor, click the triangle next to apns to show its contents. This will probably be the first item.
Click on apns and click the button that appears out to the right. It will have three horizontal lines on it.
Change the type of the item you just created to Dictionary in the type column. Click the triangle next to the Item 0 (the item you created in step 14). The button out the right will have have that same three horizontal lines icon. Click this button to make a new entry in that dictionary.
In this entry, make the key apn and the value internet. Leave the type as String.
Make another entry by clicking that same three horizontal lines icon. This time make the key password and the value password. Leave the type as String again.
Make another entry by clicking that same three horizontal lines icon. This time make the key username and the value iphone. Leave the type as String again.
Now click the triangle next to Item 1. You should see the key apn with the value containing wap. and your carrier. For me this is wap.cingular. Click on Item 1 and make another entry by clicking that same three horizontal lines icon. This time make the key type-mask and the value -2. This time change the type to Number. If you don't one of the items in the apns dictionary who's apn value has wap. in it, simply do this for all of the items in that apns dictionary.
Now click on Root at the very top of the file. Click that same three horizontal lines icon. This time make the key AllowEDGEEditing. Change the type to Boolean and check the box in the value column. Save and quit Property List Editor. We're done with all of that. Phew.
Back in Terminal, run the following command
zip $CARRIER.ipcc Payload
Now you can quit Terminal and open iTunes and connect your iPhone.
Go to the iPhone summary by selecting the iPhone from the source list on the left. Hold down option and click on Check for Update. This will open up a window to choose a file. Choose the ipcc file on your desktop. If you cannot select ipcc files here, be sure you did step 2 while iTunes was not running. You could try running this command again and restarting iTunes if you still can't select ipcc files in this dialog. If you still can't select ipcc files after this, then Apple has probably closed up this hole. Sorry.
If the window just goes away, then you did it! Simply restart your iPhone.
Open up the Settings app on your iPhone. Choose General > Network > Internet Tethering to configure it. Enjoy!
Watching different people use software is fascinating to me. My mind works a lot differently than Average-Joe's does when it comes to using software so seeing how people interact with software is really intriguing to me.
The Post Office Lady
I was just at the post office and this old lady in front of me was trying to buy a shipping label for her package. This is a very easy thing to do. There are lots of instructions, big buttons, and even instructional videos to help you if you want.
After two tries she gave up and went to go stand in the super long line to get someone to help her. (Why are the lines always stupid long in post offices? It was 2:30 in the afternoon. Why is there a line?)
She put her card into the machine when she started and then pulled it out when it told her to swipe it. It gave her a message saying please swipe it again, but I guess she thought that she had to start over and left. The other time, the machine wanted her to input the dimensions of her package and she couldn't figure out that there was a third dimension (height) to her package even thought the instructions were quite clear on the screen (there was even a picture of the box with arrows).
Why?
My guess as to why she had such problems with the system are that she has a preconceived idea of how the machine worked and when it didn't work the way she expected she figured it was broken or she wasn't smart enough to use it. That, or she just didn't understand the instructions for whatever reason, although they were very straight forward.
It is interesting to me that no matter how well you design software to be useable, some people will not be able to use it. As a developer, I don't know what to do to solve this problem. I want everyone to be able to use my software. Granted, no old people are going to use Countdown Maker, but regardless, I want them to be super easy to use.
The Other Side
The other side of all of this is OmniFocus. OmniFocus is unlike any other app I've used. The table view in it is completely custom and doesn't behave like I'd expect, they don't use any real world metaphors for their UI, and if you didn't understand GTD principals, you would be 100% confused (as I was).
The only way I was able to use this app was to watch their screen casts. After watching their screen casts, I know exactly how to use the app and I felt like a pro. This was very interesting to me as a developer. They threw out almost everything and started over. They wanted you to forget how to use software and do it their way.
I don't this this is the solution by any means, but it was very interesting to me. (I use The Hit List anyway. It's pretty.)
Now what?
Well I intend to keep making software so the old lady can use it, or at least try. If she really wanted to get her package shipped, I think she could have done it. Everything she need was spelled out for her. If I am making a pro app (think Photoshop or Final Cut) then I would go more the other side approach. I want to optimize the software for people that know how to use it instead of teaching people to use it.
I think the sweet spot is finding a balance of these two. Make the stuff people wouldn't understand more out of the way and make everything on the surface feel easy so the user can choose which path to take.