1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Learn Xcode Tools for Mac OS X and iPhone Development potx

345 1,8K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 345
Dung lượng 11,66 MB

Nội dung

Piper Learn Xcode Tools for Mac and iPhone Development Companion eBook Available Learn Xcode Tools for Mac OS X and iPhone Development Ian Piper Trim: 7.5 x 9.25 spine = 0.78125" 352 page count Mastering Apple’s programming environment for Mac OS X and iPhone OS development COMPANION eBOOK SEE LAST PAGE FOR DETAILS ON $10 eBOOK VERSION US $44.99 Shelve in Mac User level: Beginner-Intermediate www.apress.com SOURCE CODE ONLINE BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® this print for content only—size & color not accurate CYAN MAGENTA YELLOW BLACK PANTONE 123 C SPOT MATTE ISBN 978-1-4302-7221-2 9 781430 272205 5 44 9 9 W ith the Snow Leopard release of the Xcode Developer Tools, both Mac OS X and iPhone programmers have access to the most formidable, easy-to-use development tool-chest ever assembled. The only piece Apple left out is a simple and clear description of all these powerful tools and technologies. We’ve lled this void with Learn Xcode Tools for Mac OS X and iPhone Development, which gives new developers the clear explanations they need to get started, and at the same time provides detailed coverage of new, more advanced features for experienced developers. In fact, this is the rst book to examine the complete Apple Xcode developer envi- ronment for both Mac OS X and iPhone, including: • Comprehensive coverage of the entire Xcode Tool Suite: Xcode IDE, Interface Builder, Instruments, and Shark • Serious examination of the complete development process for Mac OS X and iPhone apps • Additional coverage of useful third-party development tools, including FileMerge, Plist Editor, Icon Composer, and Pixie What you’ll learn • The book is holistic—providing a broad sweep across Apple’s development tools • It is structured—logically progressing from basics to an understanding of the purpose, benets, and limitations of each of Xcode’s component Tools • It is practical, pragmatic, and thorough—showing examples of key techniques and stepping through sample projects to demonstrate the tools in action • It is developer-centric—concentrating on the ecient use of these powerful tools and techniques to write great code and build great apps for Mac OS X and iPhone • It is comprehensive—introducing the diverse tools and showing how to integrate capabilities across the toolset to build professional applications i Learn Xcode Tools for Mac OS X and iPhone Development ■ ■ ■ Ian Piper ii Learn Xcode Tools for Mac OS X and iPhone Development Copyright © 2009 by Ian Piper All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-7221-2 ISBN-13 (electronic): 978-1-4302-7220-5 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. President and Publisher: Paul Manning Lead Editors: Clay Andres, Brian MacDonald, Matthew Moodie Technical Reviewer: James Bucanek Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Mary Tobin Copy Editors: Kari Brooks-Copony and Candace English Compositor: MacPS, LLC Indexer: BIM Indexing and Proofreading Services Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com, or visit http://www.springeronline.com. For information on translations, please e-mail info@apress.com, or visit http://www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales– eBook Licensing web page at http://www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com. You will need to answer questions pertaining to this book in order to successfully download the code. iii To Caroline, Alice and Ben, at the centre of my universe —Ian iv Contents at a Glance ■Contents at a Glance iv ■Contents v ■About the Author x ■About the Technical Reviewer xi ■Acknowlegments xii ■Preface xiii ■Chapter 1: Introducing Xcode Tools for Mac OS X and the iPhone 1 Part I: The Core Xcode Toolset 7 ■Chapter 2: Introducing the Xcode Workspace 9 ■Chapter 3: Interface Builder 31 ■Chapter 4: Core iPhone Tools 61 ■Chapter 5: Frameworks in Xcode 79 ■Chapter 6: Model-View-Controller in Xcode 109 ■Chapter 7: Debugging Your Xcode Projects 119 ■Chapter 8: Xcode Documentation 139 ■Chapter 9: Developing an Application 159 Part II: Enhancing Development with Companion Tools 185 ■Chapter 10: Source-Code Management with Subversion 187 ■Chapter 11: Unit Testing in Xcode 207 ■Chapter 12: Monitoring, Analysis, and Performance Tools 225 Part III: Supporting Tools 245 ■Chapter 13: Support Tools for the Busy Developer 247 ■Chapter 14: Usability and Accessibility 271 ■Chapter 15: Packaging and Distribution 289 ■Index 315 v Contents ■Contents at a Glance iv ■Contents v ■About the Author x ■About the Technical Reviewer xi ■Acknowledgments xii ■Preface xiii ■Chapter 1: Introducing Xcode Tools for Mac OS X and the iPhone 1 Software Development Choices for the Mac Programmer 1 Why You Should Develop Using Xcode Tools 2 Xcode, Cocoa, and Objective-C 3 The Apple Xcode Developer Tools Family 4 What You’ll Find in This Book 5 Part 1 5 Part 2 5 Part 3 5 What You Won’t Find in This Book 6 Summary 6 Part I: The Core Xcode Toolset 7 ■Chapter 2: Introducing the Xcode Workspace 9 Getting and Installing Xcode Developer Tools 9 Getting Xcode 9 Installing Xcode 10 Removing Your Xcode Developer Tools Installation 12 Getting to Know the Xcode Workspace 12 The Welcome to Xcode Window 13 The Xcode Clean Screen View 13 Starting a New Project 14 The Xcode Workspace Working Environment 17 Groups & Files List 17 Detail View 19 Editor View 20 ■ CONTENTS vi  Toolbar 21 Favorites Bar 25 Status Bar 25 It’s All Gone Horribly Wrong 26 Xcode Workspace Preferences 26 General 26 Code Sense 27 Building 27 Distributed Builds 27 Debugging 28 Key Bindings 28 Text Editing, Fonts & Colors, and Indentation 28 File Types 28 Source Trees 28 SCM 28 Documentation 29 Summary 30 ■Chapter 3: Interface Builder 31 Professional User Interface Design—and More—for Your Xcode Projects 31 Getting to Know the Interface Builder Environment 32 Adding Some Controls to Your User Interface 33 Positioning and Aligning Controls and Windows 34 Autosizing Controls 36 The Library in More Depth 41 Connecting the Pieces 42 The Documents Window 42 The Inevitable Hello World Program 43 Incremental Development—Adding Features to Your Hello World Program 49 Creating a Document-Based Application 51 Implementing File Saving and Reading 53 A Little Polish 57 Summary 59 ■Chapter 4: Core iPhone Tools 61 First Things First: What You Need to Develop iPhone Software 61 Getting and Installing the SDK 62 Writing a Simple iPhone Application 63 Adding Some Polish 74 Just One More Thing 76 Summary 77 ■Chapter 5: Frameworks in Xcode 79 A Short Tour of the Frameworks 79 What Are the Frameworks? 80 Location of the Frameworks 80 Other Frameworks 81 Where to Look for More Information 81 Using Frameworks in Applications 81 The WebKit Framework—Create Your Own Web Browser 81 The Core Data Framework—Building a Simple Database Application 86 The ScreenSaver Framework 97 Summary 107 ■ CONTENTS vii ■Chapter 6: Model-View-Controller in Xcode 109 Understanding MVC 109 The Simplest Example 110 A More Complex Example 112 Summary 117 ■Chapter 7: Debugging Your Xcode Projects 119 The Debugger and Console Views 119 Creating a Project to Debug 120 Running and Debugging the Project 124 Syntax Errors 124 Debugging with Breakpoints 125 Using NSLog to Track Changing Properties 131 Checking Syntax in the Documentation 131 Exploring the Debugger 133 Debugging Features in the Code Editor 134 The Main Debugger Window 134 The Mini Debugger 136 The Console 137 Summary 138 ■Chapter 8: Xcode Documentation 139 Overview of Documentation Resources for Xcode 139 Quick Help 139 ADC Documentation 141 Cocoa Fundamentals Guide 142 Xcode Workflow and Cocoa Application Tutorials 143 Recommended Reading for Xcode Developers 143 Getting Around the ADC Documentation 144 Other Resources on the Apple Developer Site 147 Third-Party Online Resources 147 Other Sources of Information 148 Keeping a High Signal-to-Noise Ratio 148 Mailing Lists and Web Forums 149 RSS Feeds 149 Creating Your Own Developer Documentation 149 Downloading and Installing Doxygen 150 Overview of Documentation Creation with Doxygen 150 Commenting the Code 150 Creating Documentation for TemperatureConverter 152 Converting the HTML into a Docset 154 Advanced Doxygen Topics 157 Summary 158 ■Chapter 9: Developing an Application 159 Defining the Problem 159 Designing the Application 160 Sketching Out the Problem Space 161 The Data Model 162 Creating the Project 164 Choosing the Data Store Format 165 Building the User Interfaces 166 Running the Application 177 What to Do if It Doesn’t Work 178 ■ CONTENTS viii Making Improvements 178 Where to Take the Application from Here 183 Looking Back and Looking Forward 184 Part II: Enhancing Development with Companion Tools 185 ■Chapter 10: Source-Code Management with Subversion 187 Introduction to Subversion 188 The Subversion Work Cycle 189 One Repository or Many? 190 Where to Get More Information 191 Installing a Local Subversion Server 192 Creating a Repository 192 Configuring the Repository in Xcode 195 Populating the Repository with Projects 196 Getting a Working Copy out of the Repository 198 Making Changes and Committing Code 200 Comparing Revisions and Rolling Back 201 Handling Version Conflicts 202 Using an Online Subversion Server 204 Summary 205 ■Chapter 11: Unit Testing in Xcode 207 Introducing Unit Testing 207 Unit Testing in Practice 209 Setting Up a Project for Unit Testing 210 Writing Unit Tests 212 Running Your First Unit Test 213 What Should You Test? 217 Rightness 217 Wrong Input 217 Boundary Conditions 218 Other Factors to Test 219 Making Your Test Suite More Efficient 220 Where to Go Next 221 Dependent versus Independent Unit Testing 222 Summary 224 ■Chapter 12: Monitoring, Analysis, and Performance Tools 225 Instruments 225 Tracking Down a Memory Leak 225 Tracking File Activity 232 Activity Monitor 234 What Else Can You Do with Instruments? 235 Shark 236 BigTop 240 Spin Control 242 Summary 244 Part III: Supporting Tools 245 ■Chapter 13: Support Tools for the Busy Developer 247 Icon Composer 247 Creating the Basic Image for an Application Icon 248 Creating the Icon in Icon Composer 249 Pixie 254 FileMerge 256 [...]... 2–2, Xcode provides templates for a huge range of projects, though for most purposes you are likely to pick from only a few of these NOTE: At the time of writing, the Xcode Tools and iPhone Tools come in two separate installation kits If you have installed just the Xcode Tools so far, then you will see only options for creating Mac OS X development projects However, it seems likely that the Mac OS X and. .. get Xcode (actually, you may already have it!), install it, and get to know the coding environment—aka, the Xcode Workspace You will create, build, and run the simplest possible application Getting and Installing Xcode Developer Tools Before starting, it’s worth explaining some terminology Though they are often used interchangeably, there’s a difference between Xcode and Xcode Developer Tools The Xcode. .. Xcode Tools for Mac OS X and the iPhone sincere hope is that this book will help you past those learning curves, because once past them you will find Xcode an elegant, easy-to-use, and highly productive environment in which to work Of course, there is one very good reason for making Xcode your development platform of choice—the iPhone At the time of writing, there simply is no other way to create iPhone. .. these tools throughout the rest of the book Getting Xcode You may already have the Xcode Developer Tools: Apple includes them in the installation media for every new Mac In the Optional Installs folder, you’ll find Xcode Tools, and within that folder, Xcode. mpkg Given the rate of change of Xcode features (Apple doesn’t tend to rest on their laurels with any of their products, and Xcode is no exception)... ways of categorizing them Figure 1–1 The Xcode Tools family CHAPTER 1: Introducing Xcode Tools for Mac OS X and the iPhone The central components are Xcode and Interface Builder Beyond this is a range of analysis and performance-management tools and technologies There is also a variety of supporting utilities to help with refinement, usability, accessibility, and distribution of applications What You’ll... main Xcode- focused topics that I’ll be covering in the book Part 1 The first part covers the core Xcode toolset Chapter 2 introduces the Xcode program itself, covering the Xcode Workspace and code -development tools Chapter 3 describes Interface Builder and takes you through examples of interface development for different types of applications In Chapter 4 you get your first look at the tools for iPhone. .. software development, there is a good chance that you will begin to develop some curiosity about Xcode Why You Should Develop Using Xcode Tools Given the number of alternative choices, it might seem easy to dismiss Xcode Developer Tools (which you’ll often see referred to as just Xcode Tools) and Cocoa frameworks as a choice for developing software for the Mac It is fair to say, too, that historically Xcode. .. Introducing Xcode Tools for Mac OS X and the iPhone applications quickly and easily, but can be limited in their features So what if you want to create your killer application for the Mac? It’s worth mentioning REALbasic This is a great tool for software development and has a loyal following of active programmers It has a simple and easy-to-use integrated development environment (IDE) and uses the... writing iPhone apps, then you need to learn Xcode Xcode, Cocoa, and Objective-C One aim of this book is to dispel some of the confusion surrounding terminology The new developer has not only to learn a sophisticated and complex environment and toolset, but also a range of new concepts and terms In particular, the three terms Xcode, Cocoa, and Objective-C are often mixed up in the minds of newcomers to Mac. .. design and features within Xcode Tools that will make your Mac and iPhone software stand out A key partner to usability is accessibility—designing software that is usable for people with disabilities Xcode Tools provides some excellent support for building accessible software, and you will learn about this here And so to the final chapter Chapter 15 deals with getting your software out the door Most of . across the toolset to build professional applications i Learn Xcode Tools for Mac OS X and iPhone Development ■ ■ ■ Ian Piper ii Learn Xcode Tools for Mac OS X and iPhone Development. Piper Learn Xcode Tools for Mac and iPhone Development Companion eBook Available Learn Xcode Tools for Mac OS X and iPhone Development Ian Piper Trim: 7.5 x 9.25 spine = 0.78125". Reviewer xi ■Acknowlegments xii ■Preface xiii ■Chapter 1: Introducing Xcode Tools for Mac OS X and the iPhone 1 Part I: The Core Xcode Toolset 7 ■Chapter 2: Introducing the Xcode Workspace 9 ■Chapter

Ngày đăng: 01/08/2014, 13:20

TỪ KHÓA LIÊN QUAN