1 / 17

Anatomy of an iPhone Application

Anatomy of an iPhone Application. Content taken from book: “ iPhone SDK Development” by Bill Dudney and Chris Adamson. Cocoa classes.

amber
Télécharger la présentation

Anatomy of an iPhone Application

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Anatomy of an iPhone Application Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson

  2. Cocoa classes • Cocoa’s Foundation framework includes essential data classes, includes basic utilities, and establishes some core programming conventions that cannot be expressed by the Objective-C language alone • Nearly all Cocoa classes inherit from a root class, NSObject, defined in Foundation. • NSString

  3. Collection classes • Three classes are used for collecting Cocoa objects: • NSArray for ordered collections of objects, • NSSetfor unordered collections, • NSDictionaryfor mapping key objects to value objects. • These three collections are immutable—once initialized, they can’t be changed.

  4. Mutable subclasses • NSMutableArray, • NSMutableSet, and • NSMutable-Dictionary. • The collections can store only NSObjects. If you have C primitives, you can pass them around Cocoa with the wrapper classes NSDataand NSMutableData, which wrap a byte buffer, and NSNumber, an object container for any of C’s scalar (numeric) types, such as int, float, or bool.

  5. Other specific data classes • NSURL for URLs • NSDate and NSTimeZone

  6. Cocoa Touch • The “Touch” part of Cocoa Touch is largely represented by the UIKit framework, also imported by default in every iPhone application. • This framework offers the drawing model, event handling, application life cycle, and other essentials for a touch-based application. • Some user interface component classes: UIButton, UITextView, UITableView, etc.

  7. Parts of a Project • Classes—Class files are the C and Objective-C source that you create to provide the functionality of your application. • Other sources—These are source files that are generated automatically and that you are largely not responsible for or interested in. • precompiled headers file • main.mis the implementation of the main( ) function that the system calls to launch your application. • third-party library source here or procedural-C sources (.c files) that aren’t “classes”

  8. Other parts of a Project • Resources—Resources are noncode files that are nevertheless needed by your application at runtime. • Such files might include graphics or sound files, and localization dictionaries. • Frameworks—These represent the frameworks that your application uses. • By default, the Xcode template links in the frameworks Core Graphics and UIKit so you’ll be able to call the various GUI classes, and Foundation for commonly used classes such as strings, collections, and URLs. • Products—This folder represents the files that will be created by the build process, in this case the Hello.app iPhone application.

  9. XCode • Xcode is really the base for your application project. • Although you’ll use other applications to set up the GUI elements in the nib (Interface Builder), create images (any graphics application such as Photoshop or Pixelmator), and measure performance (Instruments), the job of managing all the pieces of the application and building it falls to Xcode.

  10. IBOutlets and IBActions • A reference from code to an object in the nib is called an outlet and is designated with the keyword IBOutlet. • A method that you want a nib’s objects to be able to call is an action and is designated with the keyword IBAction.

  11. HelloUserViewController.h • This code declares two outlets and one action. • (IBAction) is equivalent to (void) in that it returns no value, but using the IBAction keyword indicates our intent to connect the method to GUI events via Interface Builder

  12. Laying Out Your Interface in IB • In Xcode’s project window, double-click helloUserViewController.xib to open it with IB. • From the library, drag over three objects: a label, a text field, and a button.

  13. Customize three components as follows:

  14. Identifying Outlets and Actions

  15. Implementing the Action • HelloUserViewController.m

  16. Build Application

  17. Previous in Class Assignment • AddingViewController.h • AddingViewController.m

More Related