423 appendix A: iPhone OS class reference After this book, your main resource for learning more about the iPhone should be the references at developer.apple.com. To help you find documents that might interest you, this appendix lists the major classes in the UIK it and Foundation hierarchies that you might want to know more about, excluding classes that only appear as a part of another class. A.1 UIKit framework classes The UIK it framework contains those classes most tightly connected to the iPhone, including all of the graphical classes you use to make up pages. A partial listing appears as table A.1. It’s current as of iPhone OS 2.1, and will probably be mostly cor- rect when you read this, but the UIK it does sometimes change between releases. Table A.1 A listing of the most important User Interface classes Class Parent Summary UIActionSheet UIView A pop-up window that includes options; similar to a UIAlertView UIActivityIndicatorView UIView An indeterminate progress display UIAlertView UIView A pop-up window that includes options; similar to a UIActionSheet UIApplication UIResponder The main source for application information and control UIButton UIControl A push button UIColor NSObject A color output class 424 A PPENDIX A iPhone OS class reference UIControl UIView An abstract class that is parent to many user controls UIDatePicker UIControl A wheeled date-selection device UIDevice NSObject A class that holds info about the iPhone itself UIEvent NSObject A container for touches; part of the event model UIFont NSObject A font output class UIImage NSObject A non-displaying image holder UIImagePickerController UINavigationController A modal controller for image selection UIImageView UIView An image display that holds one or more UIImage objects UILabel UIView A small, non-editable text display UINavigationController UIViewController A hierarchical controller; often linked with a UITableView- Controller to produce hierarchical menus UIPageControl UIControl A toolbar for navigating among pages using dots UIPickerView UIView A wheel-based selection mecha- nism UIProgressView UIView A determinate progress display UIResponder NSObject An abstract class that defines all classes that can receive and respond to events UIScreen NSObject A class containing an iPhone’s entire screen UIScrollView UIView A parent class for views with mul- tiple pages of content UISearchBar UIView A text-input mechanism special- ized for searches UISegmentedControl UIControl A control for making one of sev- eral choices UISlider UIControl A control for setting discrete values Table A.1 A listing of the most important User Interface classes (continued) Class Parent Summary 425Foundation framework classes A.2 Foundation framework classes Foundation framework classes, whose names begin with NS , are almost as important as the UI classes because they represent foundational variable types, like strings and numbers. Table A.2 only lists the major classes that have some relevance to the sort of work you’ve done in this book; for more, look at Apple’s developer site under “Core Services” frameworks. UISwitch UIControl A control for selecting binary values UITabBarController UIViewController A controller for moving among multiple screens UITableViewController UIViewController A controller for displaying tables of content; often linked with a UINavigationController UITextField UIControl A control for inputting short text UITextView UIScrollView A display for text of any size UITouch NSObject An individual touch on the iPhone’s screen UIView UIResponder The abstract class that lies at the core of most UIKit objects UIViewController UIResponder A simple view controller UIWebView UIView A Safari-like web browser UIWindow UIView The root for the view hierarchy Table A.2 A listing of the most important Foundation classes Class Parent Summary NSArray NSObject An array NSAutoreleasePool NSObject A memory-management class NSBundle NSObject A pointer toward a project’s file system home NSCharacterSet NSObject Methods for managing characters NSCountedSet NSMutableSet An unordered collection of elements NSData NSObject A wrapper for a byte buffer NSDictionary NSObject An associative array NSError NSObject Encapsulated error information Table A.1 A listing of the most important User Interface classes (continued) Class Parent Summary 426 A PPENDIX A iPhone OS class reference A.3 Other classes The UI and NS classes should contain most of the objects you use when programming. We’ve also covered several other frameworks throughout this book, including the Address Book framework (chapter 16), the Address Book UI framework (chapter 16), the Core Location framework (chapter 17), the Core Audio framework (chapter 18), the Media Player framework (chapter 18), the Core Graphics framework (chapters 18 and 19), the Quartz Core framework (chapter 19), the Open GL ES framework (chap- ter 19), and the CFN etwork framework (chapter 20). Finally, you may wish to pay some attention to the Core Foundation framework, which we’ve used (as infrequently as possible) throughout part 4 of this book. NSFileHandler NSObject A methodology for controlling files NSFileManager NSObject A manager for file system work NSIndexPath NSObject A node path NSLog NSObject A very important object for debugging; logs a formatted string to the system log NSMutableArray NSArray An array that can be changed NSMutableCharacterSet NSCharacterSet A character set that can be changed NSMutableData NSData Data that can be changed NSMutableDictionary NSDictionary A dictionary that can be changed NSMutableSet NSSet A set that can be changed NSMutableString NSString A string that can be changed NSMutableURLRequest NSURLRequest A URL request that can be changed NSNotificationCenter NSObject A notification manager NSNumber NSValue A way to encapsulate many types of numbers NSObject N/A The root class for Cocoa Touch NSString NSObject A class for various sorts of string storage and manipulation NSURL NSObject A simple URL object NSURLRequest NSObject A URL plus a cache policy NSValue NSObject A simple container for data NSXMLParser NSObject An XML parser Table A.2 A listing of the most important Foundation classes (continued) Class Parent Summary 427 appendix B: External sources and references What follows are web resources that we suggest for continuing your exploration of iPhone development. B.1 General resources B.2 Web app resources Site URL Summary The Apple Blog http://theappleblog.com General Apple blog, including some iPhone discussion iPhone Atlas http://www.iphoneatlas.com iPhone news blog iPhone Dev Forums http://www.iphonedevforums.com Forums for SDK or web discussion iPhone in Action http://iphoneinaction.manning.com/ The authors’ blog for this book; we’ll keep you up to date with new links of interest and occasionally cover some of the topics that we didn’t cover in this book iPhone in Action on Magnolia http://ma.gnolia.com/people/ iPhoneInAction/ The authors’ listing of links of note Site URL Summary Apple Developer Connection http://developer.apple.com/ webapps/ The official Apple site for developer resources; requires ADC login iPhoneWebDev http://www.iphonewebdev.com/ The authors’ own site, complete with examples and webdev discussion list WebKit Open Source Project http://webkit.org WebKit home, including the Surfin’ Safari blog 428 A PPENDIX A External sources and references B.3 SDK resources B.4 Other technologies Site URL Summary Apple Developer Site http://developer.apple.com/ iphone/ The official Apple site for developer resources; requires ADC login Apple Developer Forums https://devforums.apple.com/ community/iphone Official Apple forums for SDK dis- cussion, including betas; requires ADC login Apps Amuck http://www.appsamuck.com/ Thirty-one programs with source code in 31 days Cocoa Dev Central http://cocoadevcentral.com/ A hub of Objective-C and Cocoa information Cocoa Is My Girlfriend http://www.cimgf.com/ News and tutorial blog Cocoa Samurai http://cocoasamurai. blogspot.com/ Cocoa and iPhone discussion Furbo.org http://furbo.org/ General blog that’s mostly iPhone discussion iDevKit http://idevkit.com/ Forums and news iPhone Dev SDK http://www.iphonedevsdk.com/ Forums iPhone Development http://iphonedevelopment. blogspot.com/ Blog with extensive original content iPhone Development Central http://www.iphonedevcen- tral.org/ Online iPhone tutorials Lap Cat Software Blog http://lapcatsoftware.com/blog/ Coding blog that’s mostly about iPhone and Cocoa Mobile Orchard http://www.mobileorchard.com/ A news blog Safe from the Losing Fight http://www.losingfight.com/blog/ A blog about Macs with some emphasis on iPhones Site URL Summary JavaScript.com http://www.javascript.com/ A comprehensive JavaScript site SQLite http://www.sqlite.org/ The official SQLite site W3C XML http://www.w3.org/XML/ The official XML site 429 appendix C: Publishing your SDK program All of your programming will be for naught if you don’t sign up for the iPhone Developer Program with Apple. This is a multistep process that can take quite some time, so make sure to get it all in hand well before you want to upload your pro- gram to the iPhone App Store. C.1 Signing up with Apple To get started, you must register as a developer at developer.apple.com/iphone/ program. When you register, you’ll be asked for some basic information about what you’ll be developing and you’ll need to sign Apple’s Terms & Conditions for work- ing with the iPhone. You’ve probably already done this step, as it was required to get access to the SDK and the online documentation. Sometime afterward—maybe in a few hours, maybe in a few weeks—you’ll get a call from Apple confirming your signup information and giving you the OK for the program. They’ll then send you an email that’ll allow you to finish your registra- tion. At this point, expect to pay a fee, currently $100 (standard) or $300 (enter- prise), to become a full-fledged developer. The standard program allows for distribution via the iPhone App Store, while the enterprise program allows distribu- tion of in-house applications to over 500 employees. C.2 Compiling to the iPhone The first advantage of being a registered iPhone developer is that you’ll be able to compile programs directly to your iPhone. This is fairly critical for certain types of testing. As we’ve seen in this book, features like altitude detection, volume control, and the accelerometer don’t work correctly when tested in the iPhone Simulator. 430 A PPENDIX A Publishing your SDK program To compile to an iPhone, you must create a provisioning profile, which is a multi- step process. You’ll need to use some new tools that will appear under a Program Por- tal link at the top of developer.apple.com once you’ve finished your signup and paid your fee. Apple has a complete “iPhone Developer Program Portal User Guide” that explains how to use everything here, but we’re going to outline the main steps: 1 Add team members (admin) —If you registered as a company, you can add addi- tional team members under the Team tab. The initial creator of a team will be the Team Agent, who has the highest-level powers in the Developer Program; other users will be Team Administrators or Team Members. From here, individ- ual members can set themselves up to compile to their iPhones, with some steps requiring interventions from Team Admins. 2 Create a certificate signing request (member) —This is the first step required to gener- ate the certificate you’ll need to sign (and thus run) applications on your iPhone. You create a certificate signing request ( CSR ) inside Keychain Access on your Mac and then upload it from the Certificates > Development tab; a Team Admin must then approve it. 3 Download a certificate (member) —Once your Admin (who might be you) has approved your CSR , you can download a certificate. From Certificates > Devel- opment, download the WWDR Intermediate Certificate and double-click to install it. Afterward, download your developer certificate and double-click to install it. Your certificate will now be permanently installed in your keychain. However, if you rebuild your machine or move to a new machine, you’ll lose it. To avoid this, be sure you export the private key associated with your developer certificate. You can then import it on a different machine, and redownload the two certificates from Apple. If you fail to do this, a Team Admin may need to revoke your certificate so that you can create a new one. 4 Add devices (admin) —Add any devices (iPhones or iPods) that you want to build on using the Devices tab. 5 Create an app ID (admin) —Each application needs an app ID , which controls its access to devices. For the purposes of testing, you’ll probably just use one gen- eral wildcard ID that you create by appending a wildcard (.*) to your app ID bundle identifier. 6 Create a provisioning profile (admin) —A provisioning profile is a unique combina- tion of multiple developer certificates, multiple iPhone device ID s, and a single app ID . It’s what ties your iPhone to your overall development profile and what allows you to actually run programs. You create a provisioning profile from the Provisioning > Development tab, at which point you’ll be asked to enter the three elements that make it up. 7 Download a provisioning profile (member) —Download the profile from Devices and drag it your Xcode dock icon or the organizer window of Xcode. WARNING 431Preparing for distribution via the iPhone App Store Though the setup can be a bit extensive for an admin, once the initial work is done, a member can just create a CSR , download a certificate, and download a provisioning profile. From that point, the member can choose to compile onto a device rather than to the iPhone Simulator by changing the pop-up window at the top-left of Xcode. C.3 Preparing for distribution via the iPhone App Store Preparing your program for distribution via the iPhone App Store follows much the same process as preparing your programs for testing on iPhones, except that the steps can only be undertaken by the Team Agent. 1 Create a certificate (agent) —As before, you must upload a CSR , but here you should create a certificate from the Certificates > Distribution tab, rather than Certificates > Development. 2 Create a provisioning profile (agent) —Create a provisioning profile in the Provi- sioning > Distribution tab. It will usually be an App Store profile. As before, drag your new profile to Xcode. 3 Prepare to compile (anyone) —Create a new Distribution configuration that uses the distribution provisioning profile. Update other info in the configuration, update your Info.plist as appropriate, and then build. 4 Prepare media (anyone) —Prepare a 57x57 PNG home screen icon, a 512x512 JPG / TIF large application icon, and a full-screen screenshot, as well as other infor- mation required by the iPhone App Store. 5 Upload (agent) —Go to the Distribution tab and run iTunes Connect. 6 Wait (everyone) —It’ll take a bit of time for your application to be approved and go on sale. These procedures may well change over time, but for now, this should be what you need to get your program from your desktop to the iPhone App Store. There are also two alternative ways to distribute your software: enterprise distribu- tion lets you distribute an in-house application to employees within your company, and ad hoc distributions let you distribute to up to 100 other iPhone users by email or a website. Both are explained further in Apple’s documentation. . Apple blog, including some iPhone discussion iPhone Atlas http://www.iphoneatlas.com iPhone news blog iPhone Dev Forums http://www.iphonedevforums.com Forums. SDK http://www.iphonedevsdk.com/ Forums iPhone Development http://iphonedevelopment. blogspot.com/ Blog with extensive original content iPhone Development