Random thoughts from an unusual company

Adventures in iPhone development, Part 3

Tim Davis  21 October 2008 08:45:00
Well, I've sent of my iPhone Developer enrollment request. Nothing much has happened yet. You have to specify a technical, legal and billing contact, so I put myself down for all three. The confirmation screen said that Apple would get in touch with our legal contact first, so I will wait and see what the next step is. My understanding is that they have relaxed their NDA requirements, but we'll see what I am allowed to talk about.

On the development side, I have the app communicating with our server and bringing down some dummy data. The next step is to bring down real session data and write it to the SQLite database on the device. When I say 'real session data', I mean last year's data which I am using for testing. I plan to use the same agent on the Domino side that I am using for the BlackBerry app, so both devices can use the same feed. Its a shame that the syntax for Objective-C is so alien to Java, as I can't really reuse my parsing code from the BlackBerry app.

I thought it might be interesting if I showed how the Interface Builder works, as it is very neat. Linking from the controls in your view to actions in your viewcontroller class is done by drag and drop.

Suppose we have our view open in the Interface Builder.

Image:Adventures in iPhone development, Part 3

I created the label and button by dragging the controls from the Library.

Image:Adventures in iPhone development, Part 3

The most important part of the view is the File's Owner. This is shown in the main builder window. This says what class receives events from the controls.

Image:Adventures in iPhone development, Part 3

You set the File's Owner controller class in the inspector.

Image:Adventures in iPhone development, Part 3

Back in my source code, in the AboutViewController.m file, I have this action (which simply closes/dismisses this view):

Image:Adventures in iPhone development, Part 3
To link the Close button to this dismissAction code, I start by right-clicking on the button control. This pops up a dialog with all the events I can capture for the button.

Image:Adventures in iPhone development, Part 3

The event I want is the rather dubious-sounding 'Touch Up Inside', so I click on the little circle and drag over to the File's Owner in the main builder window. (You really do get this pretty blue line).

Image:Adventures in iPhone development, Part 3

When I let go, I get another popup with a list of the available actions in my controller class.

Image:Adventures in iPhone development, Part 3

I select my dismissAction, and this shows in my events list for the button.

Image:Adventures in iPhone development, Part 3

That's pretty much it.

The other action, 'loadAction', is going to get my session data by calling the Domino agent.

One last thing I want to show is how easy it is to use the sexy effects in iPhone apps. For example, popping up a confirmation dialog with all the shading and bouncing is all done in two lines of code.

This is is the dialog. When it opened, it expanded and did that bouncy recoil animation.

Image:Adventures in iPhone development, Part 3

This is the code:

Image:Adventures in iPhone development, Part 3

The Cocoa Touch APIs do all the work for you. Very nice.
Comments
No Comments Found