iPhone First "Hello World" app
see previous article on system requirements
creates simple application with "dummy" interface meaning no event handling
Step 1: Creating a simple iPhone Application
- this application will be for iPhone only (you can choose to create application for both iPhone and iPad or only one type of device).
- Will have a simple "View" interface that only says Hello.
- No event Handling
- Launch your XCode tool
- File->New Project -> iOS -> Window-based Application (OR whatever kind of applciation you want). Select the device you are targeting (iPhone in our case)
- You will get a default directory structure as described on the iOS Xcode Project Structure page.
Step 2: Create a simple "Hello World" Interface
- Interfaces are represented in iPhone world using xib files (xml files proprietary to apple) that contain components (View objects)
- Uses Interface Builder -a main part of Xcode to build the interface
- Launch Interface Builder by double clicking on the the interface file MainWindow.xib or may be called HelloWorldViewController.xib file if you created a View type applciation. This represents the single current interface for this application
Interface Builder has multiple windows:
- Doc Window = represents the XIB file
-
- File's Owner = instanace of UIApplication = event queue for your applcation
- First Responder = ignore fo rnow (relic from desktop cocoa)
- HelloLynneDelegate = subclass of NSObject created by Xcode for this project. This is how iOS includes the Delegate pattern in development.
- View = represents this applciations main interface
NOTE: you can depending on the type of applcation you created (here View-based Application, or Window-based Application have a different elements in the Doc Window...for example Window will be the element associated with instance of UIWindow for a Window-based Application project)
- Library = contians list for drag and drop of View components --buttons, labels, text fields, etc.
- Inspector = where you can set attributes of your View components, Setup Connections ( between components and their data/model representation....MVC framework) and also Size and Info about how the application interacts.
Note that we have at the top
- tabs for Attributes, Connections, Size and Info
- Instance of View/Window = this is the actual interface you drag components to. Here it is initally blank.
- Drag and drop elements from the Libraries list of View elements to the interface you are building. Here we have dragged a Label and a button. In the Inspector Window I also set it up so the Label was centered.
- Save your file
Step 3: Run the Project in your Simulator
- Hit the Build and Run Button
- Here is an example of the "Dummy" application with no event handling that pops up in the simulator
|