Sams Teach Yourself Xcode 4 In 24 Hours

3y ago
29 Views
3 Downloads
2.05 MB
61 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Mara Blakely
Transcription

John RayWilliam RaySams Teach Yourself Xcode 424Hoursin800 East 96th Street, Indianapolis, Indiana, 46240 USA

Sams Teach Yourself Xcode 4 in 24 HoursCopyright 2012 by Pearson Education, Inc.All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, ortransmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, withoutwritten permission from the publisher. No patent liability is assumed with respect to the use ofthe information contained herein. Although every precaution has been taken in the preparation ofthis book, the publisher and author assume no responsibility for errors or omissions. Nor is anyliability assumed for damages resulting from the use of the information contained herein.ISBN-13: 978-0-672-33587-7ISBN-10: 0-672-33587-5The Library of Congress Cataloging-in-Publication data is on file.Printed in the United States of AmericaFirst Printing June 2012TrademarksAll terms mentioned in this book that are known to be trademarks or service marks have beenappropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Useof a term in this book should not be regarded as affecting the validity of any trademark or servicemark.Editor-in-ChiefGreg WiegandAcquisitions EditorLaura NormanDevelopmentEditorKeith ClineManaging EditorKristy HartProject EditorAndy BeasterCopy EditorKeith ClineIndexerTim WrightWarning and DisclaimerEvery effort has been made to make this book as complete and as accurate as possible, but nowarranty or fitness is implied. The information provided is on an “as is” basis. The author and thepublisher shall have neither liability nor responsibility to any person or entity with respect to anyloss or damages arising from the information contained in this book.Bulk SalesSams Publishing offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales. For more information, please contactU.S. Corporate and Government or sales outside of the U.S., please contactInternational Salesinternational@pearsoned.comProofreaderChrissy WhiteTechnical EditorGreg KettellPublishingCoordinatorCindy TeetersBook DesignerGary AdairCompositorNonie Ratcliff

Contents at a GlanceIntroduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1HOUR 1 Xcode 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Just Enough Objective-C and Cocoa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 Understanding the MVC Design Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574 Using Xcode Templates to Create Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715 Managing Projects and Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 956 Using the Xcode Code Source Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117.145.1657 Working with the Xcode 4 Documentation8 Creating User Interfaces9 Connecting a GUI to Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19510 Creating iOS Application Workflows with Storyboarding . . . . . . . . . . . . . . . . 21511 Building and Executing Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25112 Using Source Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27913 Xcode-Supported Languages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31114 Planning for Re-use: Frameworks and Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329.355.39915 Putting It All Together: Building an OS X Application16 Building an iOS Application17 Attaching Big Data: Using Core Data in Your Applications.43518 Test Early, Test Often . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46519 Getting the Bugs Out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48720 Keeping things Organized: Shared Workspaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50921 Advanced: Analyzing Code with Instruments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53322 Managing and Provisioning iOS Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54923 Distributing Your Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56724 Xcode CLI Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603

Table of ContentsIntroduction1HOUR 1: Xcode 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Welcome to Xcode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3The Apple Developer Programs.8Installing the Xcode Developer Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11The Nickel Tour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Preparing Your iOS Device (Optional).17Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20Q&A.20Workshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21HOUR 2: Just Enough Objective-C and Cocoa23Object-Oriented Programming and Objective-CWhat Is Objective-C?.23.25Objective-C Programming Basics.38Memory Management and Automatic Reference Counting . . . . . . . . . . . . . . . . . . . . . . . . 48What Is Cocoa? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50Cocoa Versus Cocoa Touch.51Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54Q&A.55Workshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55HOUR 3: Understanding the MVC Design PatternDevelopment, Design Patterns, and MVC.57.60.64How Xcode Implements MVCAn MVC Walkthrough57Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68Q&A.68Workshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

vTable of ContentsHOUR 4: Using Xcode Templates to Create Projects71Available Project Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71The Project-Creation Process.83You’ve Got a Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91Q&A.91Workshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92HOUR 5: Managing Projects and Resources95Getting Your Bearings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95Managing Project Files.108.110Managing Frameworks and LibrariesManaging Groups99Managing Target Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.114.115SummaryQ&AWorkshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115HOUR 6: Using the Xcode Source Editor117Understanding Editor Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117.126.131Navigating Within and Between FilesUsing the Assistant Editor.133.135Correcting Errors and Warnings in the Issue NavigatorRefactoring CodeUsing Code Snippets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138.142.142SummaryQ&AWorkshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142HOUR 7: Working with the Xcode 4 DocumentationOverview of Documentation Resources145.Configuring the Xcode Documentation Downloads.145148Understanding the Documentation Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149Using the Xcode Help Viewer.155

viSams Teach Yourself Xcode 4 in 24 HoursUsing the Quick Help Assistant. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158.161.162SummaryQ&AWorkshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162HOUR 8: Creating User Interfaces165What Is Interface Builder? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165The Anatomy of an Interface Builder File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168Creating User Interfaces.174Working with the IB Layout Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177Customizing Interface Appearance.188Setting Object Identities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191.192.193.193Adding Custom Objects to Interface BuilderSummaryQ&AWorkshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194HOUR 9: Connecting a GUI to Code195Outlet, Actions, and Properties: A Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195Making Connections to Outlets and Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197.205.211.212Writing Connection Code with Interface BuilderSummaryQ&AWorkshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212HOUR 10: Creating iOS Application Workflows with StoryboardsThe Power of StoryboardsStoryboard Terminology.215.216.218.230The Anatomy of a Multiscene ProjectMaking Advanced Segues.239.248.249A Navigation Storyboard ExampleSummaryQ&A215Workshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

viiTable of ContentsHOUR 11: Building and Executing ApplicationsThe Language of the BuildManaging Targets.251.257Managing Schemes.264.271.276.277Using the iOS SimulatorSummaryQ&A251Workshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277HOUR 12: Using Source Control279Using Xcode Snapshots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279A Brief Introduction to Source Control Systems.283Working with Subversion and Git Repositories.285Managing a Project in Source Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296.307.308SummaryQ&AWorkshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308HOUR 13: Xcode-Supported Languages311Choosing the Right Language312.Built-In Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313.322.325.326Adding Support for Other LanguagesSummaryQ&AWorkshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326HOUR 14: Planning for Reuse: Frameworks and Libraries329Understanding Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329Deploying a Framework.348Reusing Code from Existing C/C Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349.352.352SummaryQ&AWorkshop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353

viiiSams Teach Yourself Xcode 4 in 24 HoursHOUR 15: Putting It All Together: Building an OS X ApplicationGetting Started355.356Creating the Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359Attaching Code.Inserting Interface Object References into the Code.364369Tying Things Together. . . . . . .

A Navigation Storyboard Example . Mac OS X Unleashed, and Teach Yourself iOS 5 Development in 24 Hours. As a Macintosh user since 1984, he strives to ensure that each project presents the Macintosh . book to the game #Starhawk. Come play the authors and discuss Xcode in the regularly appearing

Related Documents:

Sams teach yourself regular expressions in 10 minutes / Ben Forta. Indianapolis, Ind. : Sams, 2004. 005.133 For 2004 Sams teach yourself PHP in 24 hours / Matt Zandstra. Indianapolis, Ind. : Sams Pub., c2004. 005.133 Zan 2004 Neal-Schuman directory of management software for public a

Tytuł oryginału: Sams Teach Yourself SQL in 10 Minutes, Fourth Edition Tłumaczenie: Rafał Jońca ISBN: 978-83-283-1089-6 Authorized translation from the English language edition: SAMS TEACH YOURSELF SQL IN 10

Tytuł oryginału: Sams Teach Yourself Bootstrap in 24 Hours Tłumaczenie: Andrzej Watrak ISBN: 978-83-283-2514-2 Authorized translation from the English language edition, entitled: BOOTSTRAP IN 24 HOURS, SAMS TEACH YOURSELF; ISBN 0672337045; by Jennifer Kyrnin; published

Meloni, Julie C. Sams teach yourself HTML and CSS 24 hours / Julie Meloni, Michael Morrison. -- 8th ed. p. cm. Rev. ed. of: Sams teach yourself HTML and CSS in 24 hours / Dick Oliver, 7th ed., 2006. ISBN 978--672-33097-1 (pbk.) 1. HTML (Document markup language) 2. XHTML (Document markup language) 3. Cascading style sheets. I. Morrison .

Intel Parallel Studio XE 2016 for Fortran Intel Parallel Studio XE 2015 for Fortran Java Development Kit (JDK) 1.8 Available at no charge. mathworks.com To determine the version of Xcode installed, start Xcode and then select Xcode- About Xcode. Notes for t

Before you can start developing apps, set up and make sure you have the right tools to achieve. The developing tool you are going to use is called Xcode. (From developer.apple.com) Xcode is Apple's integrated development environment (IDE). Xcode includes a source editor, a graphical user interface editor, and many other features. The iOS SDK .

9781444106022 Complete Estonian: Teach Yourself 34.99 9781444105698 Complete Filipino (Tagalog) Audio Support: Teach Yourself 29.99 9781444105681 Complete Filipino (Tagalog) Book and CD Pack: Teach Yourself 59.99 9781444105674 Complete Filipino (Tagalog): Teach Yourself 29.99 9781444195248 Complete Finnish Audio Support: Teach Yourself (New Edition) 24.99 9781444195224 Complete .

(CCSS) for Writing, beginning in early elementary, will be able to meet grade-level writing goals, experience success throughout school as proficient writers, demonstrate proficiency in writing to earn an Oregon diploma, and be college and career-ready—without the need for writing remediation. The CCSS describe ―What‖ writing skills students need at each grade level and K-12 Writing .