Your First iPhone Application PDF Manual Reference
Even though this is a very simple application, it introduces the fundamental design patterns, tools, and techniques that underlie all iPhone development using Cocoa Touch. Cocoa Touch comprises the UIKit and Foundation frameworks which provide the basic tools and infrastructure you need to implement graphical, event-driven applications in iPhone OS. It also includes several other frameworks that provide key services for accessing device features, such as the user’s contacts. To learn more about Cocoa Touch and where it fits into the iPhone OS, read iPhone OS Technology Overview. The main patterns you’re going to use are described in “Design Patterns” (page 10).
In this tutorial, little regard is given to the user interface. Presentation is, however, a critical component of a successful iPhone application. You should read the iPhone Human Interface Guidelines and explore the sample code based on this tutorial (HelloWorld) to understand how the user interface might be improved for a full-fledged application. You’ll also start to gain an understanding of how view controllers work and how they fit into the architecture of an iPhone application.
Delegation
Delegation is a pattern where one object periodically sends messages to another object specified as its delegate to ask for input or to notify the delegate that an event is occurring. You use it as an alternative to class inheritance for extending the functionality of reusable objects. In this application, the application object tells its delegate that the main start-up routines have finished and that the custom configuration can begin. For this application, you want the delegate to create an instance of a controller to set up and manage the view. In addition, the text field will tell its delegate (which in this case will be the same controller) when the user has tapped the Return key. Delegate methods are typically grouped together into a protocol. A protocol is basically just a list of methods. If a class conforms to a protocol, it guarantees that it implements the required (some may be optional) methods of a protocol. The delegate protocol specifies all the messages an object might send to its delegate.
To learn more about protocols and the role they play in Objective-C, see the Protocols chapter in The Objective-C Programming Language.
Model-View-Controller
The Model-View-Controller (or “MVC”) design pattern sets out three roles for objects in an application. Model objects represent data such as SpaceShips and Rockets in a game, ToDo items and Contacts in a productivity application, or Circles and Squares in a drawing application. In this application, the model is very simple—just a string—and it’s not actually used outside of a single method, so strictly speaking it’s not even necessary. It’s the principle that’s important here, though. In other applications the model will be more complicated and accessed from a variety of locations.
View objects know how to display data (model objects) and may allow the user to edit the data. In this application, you need a main view to contain several other views—a text field to capture information from the user, a second text field to display text based on the user’s input, and a button to let the user tell us that the secondary text should be updated. Controller objects mediate between models and views. In this application, the controller object takes the data from the input text field, store it in a string, and update a second text field appropriately. The update is initiated as a result of an action sent by the button.
Target-Action
The target-action mechanism enables a control object—that is, an object such as a button or slider—in response to a user event (such as a click or a tap) to send a message (the action) to another object (the target) that can interpret the message and handle it as an application-specific instruction. In this application, when it’s tapped, a button tells the controller to update its model and view based on the user’s input.
Adding a View Controller Class
View controller objects play a central role in most iPhone applications. As the name implies, they’re responsible for managing a view, but on iPhone they also help with navigation and memory management. You’re not going to use the latter features here, but it’s important to be aware of them for future development. UIKit provides a special class—UIViewController—that encapsulates most of the default behavior you want from a view controller. You have to create a subclass to customize the behavior for your application.
>> In Xcode, in the project organizer select either the project (HelloWorld at the top of the Groups and Files list) or the Classes group folder—the new files will be added to the current selection.
>> Choose File > New File and in the New File window. Select the Cocoa Touch Classes group, then select UIViewController subclass. In the Options section, choose With XIB for user interface.
Download Your First iPhone Application PDF Manual Reference
Others Search:
apple ccolor 1 5 user manual pdf, free dvd pdf manuals download, htc disable notifications touch after a call diamond, mac os 9 1 user guide, windows 7 user manual pdf, your first iphone OS applicationComments
Leave a Reply