Developing for iPhone

Learn how to create and develop iPhone applications from scratch.

Archive for the ‘iPhone’ Category

Tutorial 4-2: Keyboard Input

Posted by Henry On July - 26 - 2009 1 COMMENT

Go ahead and open the Story Time project from the previous tutorial. In the resources folder, double-click “FlipsideView.xib” to open the interface for the application’s flipside view. This is where we will have a number of inputs to change the content of the story. By using Labels and Text Fields from the library in Interface Builder, create an interface that looks like this:

iPhone Development Tutorials

iPhone Development Tutorials

Read the rest of this entry »

Tutorial 4-1: Other Templates

Posted by Henry On July - 16 - 2009 1 COMMENT

In the previous tutorial, we used a view-based application template. These consist of just one view or screen. Today, let’s try out a new template. Follow the instructions below to get started:

1. In XCode, click File > New Project
2. In the left pane of the new window, click Application under the iPhone OS heading
3. In the right pane, click Utility Application and then click the Choose button
4. Name the project “Story Time” and click Save.

The Utility Application template we chose this time, sets up a nice flipping function for us. This means we can flip between two different views. Have a look at your new project window. You will notice that in the left pane, we have folder for the main view and a folder for the flipside view. Each of these folders contains some basic classes already set up for us. Now click on the Resources folder. You should see an interface file (.xib) for both the main view and the flipside view. Click “Build and Go” to test it out. Once the simulator is running, you can click the “i” icon at the bottom of the screen to flip over to the other view, then click the “Done” button to flip back. Cool huh?

Read the rest of this entry »

Tutorial 3-3: More Interface Connections

Posted by Henry On May - 2 - 2009 3 COMMENTS

Go ahead and open the “HelloiPhone” project from the previous tutorial. Remember the slider we added to the interface? Today we will give it some functionality.
Open “HelloiPhoneViewController.h” and edit it to look like this:

#import <uikit /UIKit.h>
 
@interface HelloiPhoneViewController : UIViewController {
	IBOutlet UILabel *sliderValue;
}
 
@property (nonatomic, retain) UILabel *sliderValue;
 
-(IBAction) sliderChanged: (id) s;
-(IBAction) goButton;
 
@end
 
</uikit>

Read the rest of this entry »

Tutorial 3-2: Interface Connections

Posted by Henry On May - 1 - 2009 1 COMMENT

Open the “HelloiPhone” project we worked on in the previous tutorial.

Today we will start by adding a button to our interface. So click the Resources folder in the project window and double click “HelloiPhoneViewController.xib” to open the Interface Builder. We already have a label set up, so let’s add a button below it. In Interface Builder, select “Round Rect Button” in the Library window and drag it onto your view just below the label we created. Double click on your new button and type in “GO”. Feel free to move or resize the button however you want. You can resize using the blue dots when the button is selected. When you are happy with your button, proceed to the next step.

We have a button now, but it doesn’t do anything yet. Let’s add a slider and then we can add functionality to them later. Drag a “Silder” from the Library window to your view somewhere below the button. Resize it to fill the width of the view. Now drag another “Label” from the Library and place it below the slider. This label will change when the slider is moved with the help of some code. Change the label to say “0.5″. When the slider is to the left, we will set the slider label to 0 and set it to 1 when it is to the right. Since we are initializing the slider in the middle, the label should initially read 0.5. Highlight the new label and set the alignment to the center. This can be done in the Attributes Inspector. Your interface should now look something like this:

Read the rest of this entry »

How to develop iPhone applications on Windows

Posted by Henry On April - 24 - 2009 ADD COMMENTS

I see a lot of people asking this question.

The simple answer is you can’t. Not at the moment anyway, and there aren’t any signs on the horizon either. You wouldn’t expect Microsoft to allow Mac users to develop XNA games on the Mac would you? Of course, it would be nice. As a primary Windows user myself, I would rather be creating developing iPhone applications in the familiar Windows environment, but it’s just one of those things.

However, don’t be put off by the price of a Mac. The Mac Mini may not be as powerful the iMac or Mac Pro, but its cheap and you dont need much power if you are developing iPhone applications. A Mac Mini has more than enough horse-power for that. On top of that the iPhone SDK (software development kit) is absolutely free!

Tutorial 3-1: Hello iPhone!

Posted by Henry On April - 24 - 2009 1 COMMENT

Ah yes, the moment you have been waiting for. Time to write an iPhone application. If you have not completed the previous tutorials, I suggest you do that now.
Follow these steps to get started:

  1. In XCode, click File > New Project
  2. In the left pane of the new window, click Application under the iPhone OS heading
  3. In the right pane, click View Based Application and then click the Choose button
  4. Name the project “HelloiPhone” and click Save

You will notice that there are a few folders set up for you in the left pane of the project window. For now you don’t need to know what all the files in each folder do.
Click Build and Go. A new application will open called iPhone Simulator, and in it comes a nice shiny iPhone for you to play with. This is where you can test your applications. As soon as it loads, it will boot up the application that you just created. You haven’t done anything to it yet so it is just a gray screen. Press the home button (the square symbol at the bottom) to exit the application. Go ahead and play around with it – use it just like a real iphone but use your mouse to control it instead. Try clicking Hardware > Rotate Left or Right to flip the iPhone on it’s side.

There are some things that the iPhone simulator can’t do. It doesn’t include things like GPS to find it’s location or an accelerometer to detect movement or tilting. You also cant use multi-touch as you only have one mouse. For these things you will need to test on a real iPhone. However, you are only allowed to use a real iPhone if you have paid for and been accepted to Apple’s Standard Developer Program or higher. But for learning the basics, the simulator is fine.

Quit the simulator when you are done and return to XCode.

Read the rest of this entry »

Why?

Posted by Henry On April - 11 - 2009 ADD COMMENTS

Welcome to Developing For iPhone.

A couple of months ago, I decided that I wanted to develop an iPhone application. However, there were a couple of problems with this:

  1. I had hardly ever used a Mac before.
  2. I had never even touched an object-oriented programming language.

So here I am, trying to learn the basics of developing for the iPhone with very little knowledge on the subject. I have decided to complement my learning by writing tutorials on what I have learned so far. So if you want to start learning – why not join in with me? I am hoping to give new developers a kick-start and learn a few things myself in the process. This may not be much help for programming gurus who already know their stuff, but if you are one, I encourage you to join in and help out!

If you find a problem in a tutorial or think it could be better, please don’t hesitate to leave a comment to help everyone out!

That said, let’s jump right in from the beginning. See the tutorials page for the first tutorial.