Xcode_Quick_Start_Guide.pdf

(6477 KB) Pobierz
Xcode Quick Start Guide
Xcode Quick Start Guide
Tools&Languages:IDEs
2011-05-07
695712240.001.png
Apple Inc.
© 2011 Apple Inc.
All rights reserved.
Somestatesdonotallowtheexclusionorlimitation
ofimpliedwarrantiesorliabilityforincidentalor
consequentialdamages,sotheabovelimitationor
exclusionmaynotapplytoyou.Thiswarrantygives
youspecificlegalrights,andyoumayalsohave
otherrightswhichvaryfromstatetostate.
Nopartofthispublicationmaybereproduced,
stored in a retrieval system, or transmitted, in
any form or by any means, mechanical,
electronic, photocopying, recording, or
otherwise, without prior written permission of
Apple Inc., with the following exceptions: Any
person is hereby authorized to store
documentation on a single computer for
personal use only and to print copies of
documentation for personal use provided that
thedocumentationcontainsApple’scopyright
notice.
The Apple logo is a trademark of Apple Inc.
No licenses, express or implied, are granted
withrespecttoanyofthetechnologydescribed
in this document. Apple retains all intellectual
propertyrightsassociatedwiththetechnology
described in this document. This document is
intended to assist application developers to
develop applications only for Apple-labeled
computers.
Apple Inc.
1 Infinite Loop
Cupertino, CA 95014
408-996-1010
App Store is a service mark of Apple Inc.
Apple, the Apple logo, Cocoa, iPod, Mac, Mac
OS, Objective-C, Quartz, and Xcode are
trademarks of Apple Inc., registered in the
United States and other countries.
IOS is a trademark or registered trademark of
CiscointheU.S.andothercountriesandisused
under license.
EventhoughApplehasreviewedthisdocument,
APPLEMAKESNOWARRANTYORREPRESENTATION,
EITHEREXPRESSORIMPLIED,WITHRESPECTTO
THISDOCUMENT,ITSQUALITY,ACCURACY,
MERCHANTABILITY,ORFITNESSFORAPARTICULAR
PURPOSE.ASARESULT,THISDOCUMENTIS
PROVIDED“ASIS,”ANDYOU,THEREADER,ARE
ASSUMINGTHEENTIRERISKASTOITSQUALITY
ANDACCURACY.
INNOEVENTWILLAPPLEBELIABLEFORDIRECT,
INDIRECT,SPECIAL,INCIDENTAL,OR
CONSEQUENTIALDAMAGESRESULTINGFROMANY
DEFECTORINACCURACYINTHISDOCUMENT,even
ifadvisedofthepossibilityofsuchdamages.
THEWARRANTYANDREMEDIESSETFORTHABOVE
AREEXCLUSIVEANDINLIEUOFALLOTHERS,ORAL
ORWRITTEN,EXPRESSORIMPLIED.NoApple
dealer,agent,oremployeeisauthorizedtomake
anymodification,extension,oradditiontothis
warranty.
695712240.002.png
Contents
Introduction AboutXcode 7
At a Glance 7
The Workspace Window Manages Projects 7
Contextual Help Provides Focused Assistance 8
How to Use This Document 8
See Also 8
Chapter1 Tutorial:UsingXcodetoWrite“Hello,World!”forMacOSX 9
Create the Cocoa Application Project 10
Create the NSView Subclass 12
Design the User Interface 15
Write the Code 22
Run the Application 27
View Task and Session Logs 29
Chapter2 Tutorial:DesigningaUserInterfacewithInterfaceBuilder 31
Use Interface Builder To Create the User Interface 31
Creating the Viewer 32
Adding the Pause/Play Button 40
Adding the Load Button 43
Connecting Actions and Outlets 45
Add Implementation Code to Complete the Application 48
Verify the Code Added by Interface Builder 48
Add Implementation Code 49
Test the Load Button 50
What’s Next? 51
DocumentRevisionHistory 53
2011-05-07 | © 2011 Apple Inc. All Rights Reserved.
3
695712240.003.png
CONTENTS
4
2011-05-07 | © 2011 Apple Inc. All Rights Reserved.
Figures and Listings
Chapter1 Tutorial:UsingXcodetoWrite“Hello,World!”forMacOSX 9
Figure 1-1 The Hello application in action 9
Figure 1-2 The Interface Builder dock and canvas 16
Figure 1-3 Interface Builder dock in list view 16
Figure 1-4 The utility area in the workspace window 18
Figure 1-5 The source editor 22
Figure 1-6 Hello application stopped at a breakpoint 28
Figure 1-7 The log viewer in the workspace window 30
Listing 1-1 Initial implementation of the HelloView class 23
Listing 1-2 Implementation of the drawRect: method 26
Chapter2 Tutorial:DesigningaUserInterfacewithInterfaceBuilder 31
Figure 2-1 The QCDemo window 32
Listing 2-1 The QCDemoAppDelegate header file 48
Listing 2-2 The QCDemoAppDelegate implementation file 49
2011-05-07 | © 2011 Apple Inc. All Rights Reserved.
5
695712240.004.png
Zgłoś jeśli naruszono regulamin