Guide to Apple IPhone and ITouch Application Programming Part 4

Chris Chen
Before I get started with the tutorial, I was just letting you guys know that I've put up some video tutorials on iPhone programming that follows the text series. The thing is with the videos is that it takes about a week to a week and a half to get them reviewed by AC whereas I can pop out these tutorials in about thirty minutes and just skip the review process. If you're having problems following this text tutorial or if you just need some reinforcement, go ahead and check out the videos. They will be up by the time you read this installment. I have the entire first program that is the "iStart" in those video tutorials, showing you how to do everything from setting it up to linking everything together but maybe I'm getting too far ahead of myself. If you want links, take a look at the side where the links usually are. Hopefully I won't forget to put them there like I usually do.

Let's start where we last left off. We had just finished creating all the buttons and writing the entire source code. And I specifically remember you smashing the keyboard against the ground and screaming, "Why isn't this working?" Fear not though, the answers you've been waiting for and the conclusion to your very first independent iPhone application is just around the corner. Alright, all you need to do is to go ahead and open up the Interface Builder file which, if I'm not mistaken, is named [iStartViewController.xib] or [MainWindow.xib]. You can open either one, it doesn't really matter. Once you've opened that up, go ahead and right click on the label first. You will see a little box pop up and there will be a little circle with the text "New Referencing Outlet" directly to its left. Click and hold the little circle and you will see a line. Drag and drop that line directly to the box with "File's owner." When you finish, you should see a box pop up with two things. The top thing should be "labelName" which is the variable we defined in our code. The second one is "view" and we won't be using that yet. Just click on the "labelName" and you should see an immediate change in the first box you opened. Again, if this is confusing to you, the video will help you a lot. What we just did is connect the label to the variable so we can modify it or get its value in the code. Without this link, we would have no connection to this outlet.

The next step is to connect our button to the method we defined in the code. Let's perform the same procedure. If you right click the button, you will notice something very different though. There are many more options this time. Scroll down and hit "Touch Up Inside." Then, drag to the File Owner and select the method we defined which was "buttonPressed." Then save up the file, and you're all ready to go. This is the conclusion to your very first iPhone application project. Look for the links at the side for video help. Thanks for reading and look forward to my next tutorials in which we explore more complex programs and how to connect to popular social networking sites such as Facebook and Twitter. Also, don't forget to comment, rate, and to ask any questions if you have them.

Published by Chris Chen

Chris is currently attending the University of California, Berkeley seeking an undergraduate's degree in Electrical Engineering Computer Science. He enjoys playing basketball, practicing kendo, hanging out w...  View profile

To comment, please sign in to your Yahoo! account, or sign up for a new account.