Home
Wiley Xcode 4
Contents
1. 0008 0 Selecting and navigating files Xcode 3 included a pair of file and symbol navigation menus above the main editing pane Xcode 4 extends this idea and displays a hierarchical navigation bar that generates a menu tree from your project files listing the files and symbols As shown in Figure 1 6 you can select any file almost instantly fer 13 introaqucing Acode 4 l Figure 1 6 The navigation bar drastically speeds up access to any file in your project by presenting them all in a single unified menu tree ane 18 18ViewController h Ea Archive IB Succeeded 25 02 2011 at 0131 No hssuss gt BAppDelegate h as H B eeraa C Other Sources gt m BAppDelegate m ce z BS C Resources gt BViewController h v ses le F vi 7 h IBAppDelegate h 1 Created by Richard wy Mil Frameworks gt R wviewcontrotter m mi IBAppDelegate m Copyright 2010 Skydas il Products gt hi i8view h hy IBviewControllee h ti E R eview m Sinport lt UIKit UIKit he eel Metta interface TBViewCont roll Ivi Ver interface IBViewController UIViewController a UTLabel _theLabel D Other Sources D Resources gt L Frameworks IBAction buttonWasTapped id sender Y C Products oroperty nonatonic retain TBdutlet UILabel thelabel yA ThisApp ong app end 008 8 NOTE In beta versions of Xcode 4 you could use the menu tree to navigate to the methods in each fi
2. Working with Interface Builder IB is now built into Xcode 4 It launches at the same time as Xcode and you can edit a nib file simply by selecting it IB in Xcode 3 had the same poor window management as the main edi tor IB s windows would often hide behind other windows for no reason In Xcode 4 you can use tabs the navigation bar and other new editor features to work with multiple files more efficiently Linking and symbol editing have also been drastically simplified You can drag links directly from a control or object in IB to a code window as shown in Figure 1 10 Xcode inserts appropriate code for you in both the header file and the implementation It also synthesizes outlet variables automatically For detailed examples of creating links among outlets actions and IB objects see Chapters 7 and 8 Figure 1 10 Creating outlet code automatically in Xcode 4 This is a very powerful time saving feature ane _ Tango gt H Tango iPhone Simul m Er A Diao A TangoViewController xib T a4 gt Tango 1 Segmented Control First Second 4 ii Top Level Objects TangoViewController h No Selection lt 1dD gt TangoWiewController h Tango Created by Richard Wentk on 28 04 2010 Copyright Skydancer Media 2010 All rights reserved inport lt UIKit UIKait h gt inport TangoView h interface TangoViewController UIView ontroller goView thisTangovig Ce ee M ert Ou
3. F420 main void applicationDidfinishLaunching NSNotification aNotification y yg Thread 2 ff Insert code here to initialize your application M com apple libdispatch manager 5 Thread 1 Stopped at breakpoint JO havent void dealloc E5 star_wathread k window releasel M Thread 3 wanaged0bjectContext releasel persistentStoreCoordinator release wanaged0bjectModel release r E o _workg_kernreturn E 2 star_waqthread super dealloc E gt amp 4hello app gt Mt Thread t gt Do helloAppDelegate applicationDidFinishLaunching Local Q All Output Clear 10 W oH E cmd SEU 0x93b06432 applicationDidFin shLaunching GNU gdb 6 3 5 20050815 Apple version gdb 1585 Tue z i Aug 18 07 24 19 UTC 2810 VEN aNotification NSConcreteNouficadon 0x247210 NS o Pyright 2004 Free Software Foundation Inc P NSObject NSObject GOB is free software covered by the GNU General VED self thelloAppDelegate Ox11bbe0 Public License and you are P NSObject NSObject welcome to change it and or distribute copies of it gt window NSWindow 0x21e9e0 under certain conditions Type show copying to see the conditions gt persistentStoreCoordinator NSFersistentStoreCoord there is absolutely no warranty for GDB Type show gt managedObjectModel NSManagedObjectModel 0x9 warranty for details gt managedObjectContext NSManagedObjectContext 0x0 This GO
4. It includes a new Library sub pane that can dis play file templates standard code snippets standard system objects that include both UI and data classes and project media files The Code Snippet feature in the Library is shown in Figure 1 12 It s often useful to reuse the same code between projects and the Code Snippet makes it easy to do this To add code toa project drag it from the library and drop it in the editor window You also can view previews of each snippet by selecting it before dragging By default this pane includes a small selection of standard snippets but you can extend it indefinitely by adding your own For more details see Chapter 9 ter ic Introqucingd Acodgde 4 E m Figure 1 12 The new Code Snippets feature makes it easy to reuse code and is a partial replacement for Xcode 3 s Code Sense macros TangoViewController h Vf Tango FileName TangoViewController h File Type Default C Header Source J Created by Richard Wentk on 28 84 2010 Copyright Skydancer Media 2010 All rights reserved inport lt UIKit UIKit n gt inport TangaView h Gj Code Snippet Library interface TangoViewController UlViewController TangoView thisTangoView TaGutlet UISegnentedControl esegrent Objective C init Method property nonatonic retain IB0utlet TangoView Objective C Protocol Definition thisTangoView Qend Objective C Catch Blo
5. Key Features For developers who are beginning Xcode Xcode 4 includes the following features A project navigator that lists and groups related project files File and project templates for both OS X and iOS projects eeee Getting Started 4 SESSA A code editor that includes static code checking code completion and dynamic hints and tips A visual UI design tool called Interface Builder also known as B which can prototype visual interfaces but can also be used to manage and preload other application objects Further integrated editors for class management and for Apple s Core Data database framework A debugger that supports expressions and conditional breakpoints Support for direct access to various online code repositories A minimal but useful iPhone Simulator that runs iOS applications on a Mac A collection of Instruments tools that can profile speeds monitor memory alloca tions and report other key features of code as it runs Support for both visual development and low level command line compilation An impressive selection of further helper applications that aren t built into the main Xcode interface but are installed with Xcode and can be run independently as needed The tools include a packager for building installable OS X applications hard ware monitoring and testing an animation design tool a tool for building JavaScript widgets that can be distributed commercially and others C
6. ong x4 Info plist tnfoPlist strings MainWindow xib x4ViewController xib Y C Frameworks D Ukit framework O Foundaton framework gt I CoreGraphics framework Products OAG Q EEZ x ppDelegate n x Created by Richard Wentk on 18 09 2010 Copyright c 2018 Skydancer Media Ltd All rights reserved inport xdAppOelegate h inport x4ViewController h inplementation x4Appde legate synthesize window synthesize viewController BOOL application UIMpplication application didFinishLaunchingWithOptions NSDictionary LaunchOptions Override point for customization after application Launch window addSubview viewController view window makeKeyAndVisible return YES voidjapplicationWillTerminate UlApplication application NSLog Quitting void deattoc window releasel viewController releasel super deallocl Gend x4AppDe legate h x4 Created by Richard Wentk on 18 89 2018 Copyright c 2010 Skydancer Media Ltd All rights reserved t import lt UIKit UIKit h class x4ViewController Ginterfoce x4AppDelegate NSObject lt UTApplicationDelegate gt UIWindow window x4ViewController viewController property nonatomic retain IBOutlet UIWindow window property nonatomic retain IBOutlet x ViewController xviewController end Understanding the History o
7. other than the default portrait orientation BOOL shouldAutorotateToInterfaceOrientation UlInterfaceDrientation interfaceOrientation Return YES for supported orientations return interfaceOrientation UlInterfaceOrientationPortrait s void didReceivcMemoryWarning ff Releases the view if it doesn t have a superview super didReceiveNenorywarning Release any cached data inages etc that aren t in use vold viewDidUnload 1 Release any retained sudviews of the main view e g self myOutlet nil void dealloc super deatlocl Qend Using the Assistant Xcode 3 included a counterpart file selector that switched an editor window between a class header and its corresponding implementation file Xcode 4 introduces Assistant which is designed to work with a new vertically split double pane view When you select a file for edit ing Assistant makes an informed guess about a useful counterpart and displays it automati cally as shown in Figure 1 8 By default this means that selecting a header displays the implementation file in the second pane and vice versa er f iIntroacucind Acoage 4 Figure 1 8 The button for selecting the Assistant option is in the grouping at the top right and looks like a light bulb It splits the editor into two panes and automatically displays a counterpart file whenever a file is selected Lam h Y L 1 target 105 Device SDK 4 1 TangoViewContr
8. unrealistic Currently iOS and OS X applications have distinct markets and partially distinct distribution models Although a few applications have appeared on both social networking tools and games are the most popular choices Xcode does little to simplify the development of multi platform projects Getting Startec The development workflow is almost completely distinct The two platforms have these features A separate collection of classes for UI design and for data management Many of the more creative and sophisticated classes in OS X are either absent or only partially implemented in iOS A separate testing and debugging environment iOS applications can run in a Simulator or on a hardware device OS X applications run in a debugging sandbox Adifferent core programming model iOS supports task switching with very limited multi tasking and limited access to the device file system OS X supports a wider range of multi tasking options and less restricted access to files Separate documentation suites iOS and OS X have separate collections of docu mentation and distinct source code examples Different accelerated graphics frameworks OS X implements OpenGL in full iOS implements the simpler OpenGL ES framework Different project templates for separate bare bones starter application sketches iOS includes a set of sketches for simple Ul driven handset apps OS X includes a more complex collection of templ
9. B was configured as i386 apple darwin tty dev ttys000 sharedlibrary apply load rules all Switching to process 4602 gdb Comparing iOS and OS X Development Although Xcode supports OS X and iOS development equally and it can be used to develop apps for both the iOS and Mac App Stores there are significant differences between the two platforms Developing for OS X OS X development in Xcode 4 is build and go There are no restrictions on development test ing or distribution You can create applications that run in a debugging environment on your own Mac and package them as applications that you can run independently sell from a web site or prepare for network distribution You can also create Mac apps for the App Store but this is one development option and not an obligation Figure 1 14 shows a simple OS X applica tion using a template as a starting point cnap NOTE Xcode doesn t include network deployment features But it does create application binaries that can be handed to net work deployment tools Earlier versions of Xcode supported universal binary development which was backward compatible with PowerPC hardware Although OS X 10 6 Snow Leopard was the first Intel only version of OS X Xcode supports universal binaries for Mac development and can still be used to develop applications for PowerPC targets It continues to support AltiVec hardware accelera tion The commercial market for PowerP
10. C applications is tiny but PowerPC applications remain interesting in specialized media and scientific computing Figure 1 14 Create a very simple OS X application using a template as a starting point and adding a text label in IB The application runs in its own window and replaces the OS X menu bar not shown here Although it appears to run independently it is in fact controlled by Xcode and can be debugged while it s running oD Q HELLO hello Ri hell rey gt hello Local Mac 32 siete Ama ma B Project 3 pi MainMenuxib F amp B ui jiakz e 6 mia hello gt C Resources gt MainMenu xed gt J MainMenu xib English gt i Window hello gt Ez View lt gt cD By Type Ptacehotders hello File Edit Format View Window Help lo A Y issues File s Owner gt helloAppDelegate m O First Responder a pApApalication Shared User Defaults Con TH Objects gt DO Main Menu lis Window hello v E view HELLO ue 2 ahelloapp Developing for iOS iOS development is more complicated than OS X development Development is controlled by provisioning an Apple generated security control which is built into Xcode and manages access to hardware testing and App Store distribution iPhone iPod touch and iPad platforms all use iOS but these platforms are significantly different and may not always run
11. Introducing Xcode 4 gt X code is Apple s free suite of developer tools it is used to cre ate applications for iOS mobile devices and for Mac OS X Xcode 4 shown in Figure 1 1 is the most recent version and is a radical update with many new features Developer tools are complex and Xcode has always tried to hide much of that complexity from novice developers You can use Xcode in a very simple click to build way but this simplicity can be misleading Many developers never explore Xcode s more advanced features and never discover how they can use them to save time solve problems or extend their projects with original and creative features Xcode also includes an unexpectedly enormous selection of helper applications and developer tools A complete guide to every ele ment in Xcode would require a shelf of books This book concen trates on beginner and intermediate level features but also includes hints and pointers for advanced developers In This Chapter Understanding the history of Mac development tools Developing Xcode Moving to Xcode 4 Comparing iOS and OS X development Figure 1 1 Xcode 4 s simplified interface hides familiar old features and some unexpected new ones mnreasz er Y L 1 target 105 Device SDK 4 1 Y 0 Classes x4AppDelegate h xdAppDelegate m x4ViewController t x4ViewController m Y C Other Sources gt x4 _Pre ix pch main m Y C Resources E help2
12. ROSS REFERENCE For a list of helper tools and applications see Appendix A Xcode doesn t support or include the following 3 d Editors for graphics sounds fonts 3D objects or other media types External edi tors must be used Built in support for languages other than C C and Objective C You can extend Xcode to work with other languages but Xcode is optimized for C family develop ment This does not include C Development tools for other operating systems OS X is similar enough to BSD UNIX to allow for some code sharing But Xcode cannot be used to develop applica tions for Windows Android or Linux or for web languages such as Perl and PHP Unlocked open development for iOS Applications for iOS hardware must be code signed and linked to a time limited certificate In practice this means that even if you use Xcode own an iPhone and are a registered developer your own applications will cease to run after the time limited certificate expires Development on non Apple platforms Currently Xcode requires a Mac running a recent copy of OS X Chapter 1 Introducing Xcode 4 NOTE Rumors surface regularly of a merger or at least a relationship between Xcode and Microsoft s Visual Studio series of development tools There would be obvious commercial benefits to allowing Windows developers access to i0S and the App Store but Apple s culture tends to be closed and proprietary A formal link is possible
13. _ classes Tango FileName TangoViewController h i TangoAppDelegate n Created by Richard Wentk on 28 84 2010 File Type Default C Header Source E E pele Copyright Skydancer Media 2010 All rights reserved A ats maeti 1 Location Relative to Group f Bi TangoViewControtler h L TangoViewController m inport lt UIKit UIKit h gt i m Tangoview n inport TangoView h Full Path Volumes Developer STORE b 5 1 finger TangoView m interface TangoViewController UIViewController itp annaa acies TangoToken h TangoView thisTangoView TangoToken m IBOutlet UTSegnentedControl segment Localization C Other Sources Y C Resources property nonatonic retain 180utlet TangoView No Localization gt TangoViewControllerxity thisTangoView MainWindow xib blej Tango Info plist gend Y Target Membership w C Frameworks D A Tango No Role D Ukit framework D Foundaton framework O CoreGraphics framework C Products F Text Settings Text Encoding Unicode UTF 8 Line Endings Unspecified Mac OS X Unix LF ES Indent Using Spaces Widths iai gia Tab Indent A wrap lines b Source Control iDO 6 Jj Fite Template Library Zia Application An intertace Builder document m sultable for creating an IPhone iPod Touch application including an application s i OAR Q a The utilities pane is also shown in Figure 1 11
14. ac and MonoTouch versions include bindings to key OS X and iOS APIs A version for Android is also available The main IDE is called MonoDevelop and is available at monodevelop com Although Mono has obvious advantages Apple s support for the competing platform isn t reliably enthusiastic At times Apple has barred from the App Store apps developed in languages other than C Objective C and C But some MonoTouch applications have been approved for sale Mono may be a better choice for developers coming from a C and Windows background who don t want to learn a completely new language On the iPhone Flash developers can package Flash projects as iPhone applications with Adobe s Packager for iPhone Originally included in various versions of Adobe CS5 Packager was withdrawn when Apple restricted iPhone applications to native Objective C and C code Apple subsequently lifted the restrictions later in 2010 and at the time of writing Packager is available as a free beta project from the Adobe Labs site at Labs adobe com Future production versions are likely to have their own URL and product pages iPhone game developers may also want to consider Ansca s Corona which is a simplified scripted development environ ment for i0S and Android available from ansca mobile com corona Corona currently costs 349 per year but claims faster development times than are pos sible with Xcode and native Objective C Understanding Xcode 4 s
15. ates that support the development of plug ins screen sav ers and other libraries A partially distinct set of supported instruments for testing Limited overlap exists but some instruments remain unique to each platform Apple s Model View Controller design pattern implies that applications should keep UI designs UI management code and underlying data collections distinct OS X includes controller classes that make it easier to manage data and create Uls to work with it Most of these classes are absent in iOS This makes it difficult to use MVC effectively when attempting dual platform development If you plan to develop across platforms try to package the underlying data model into its own collection of classes You may be able to reuse these classes without major changes Keep UI and UI management code elsewhere Generally combined iOS and OS X remain possible but difficult It s more realistic to think of Xcode 4 as two separate development environments with a common frontend than as a single unified environment designed to produce code for either platform Summary This chapter explained how previous Mac development tools led to Xcode listed the key design goals of Xcode 4 and summarized the key differences between Xcode 4 and Xcode 3 It intro duced some of the practical differences in more detail and looked at some of the new features Finally it explored the fundamental differences between iOS and OS X development and bri
16. but at the time of writ ing it seems very unlikely Moving to Xcode 4 Xcode 4 marks a significant change because the aim is no longer to produce code but to sim plify the developer experience Many developer tasks are repetitive chores that have become embedded in the development process for historical reasons Developer tools typically assume a workflow and mindset that date back to the very earliest days of computing more than half a century ago The designers of Xcode 4 have begun to rethink some of these assumptions adding features that can streamline and simplify the workflow Some of these features are specific to Cocoa and Objective C development while others are more general improvements in code management and debugging Compiler technology has also improved and Xcode 4 is moving toward the lat est and fastest compiler tools CROSS REFERENCE For details of the compiler technologies available in Xcode 4 see Appendix C Compared to Xcode 3 Xcode 4 has a completely redesigned interface and a selection of extra features A unified interface in a single window Integrated editors for all main code and data file types Integration of Interface Builder the Xcode visual UI design tool Simpler and faster navigation between files eeee Integrated code management with version control repository access and a code library to simplify reuse of code snippets Improved debugging and code testing with more informative error mes
17. ck Objective C Class Declaration C Block typedef Objective C dealloc Method All Platforms void dealloc Objective C dealloc Method deallocations ra super dealloc Objective C Try catch Block Objective C Fast Enumeration crvpeder k a Edit Done l a ed Exploring the debugger As shown in Figure 1 13 the debugger now appears in a new pane at the bottom of the editor window To reveal it select View Show Debugger Area Both console output and debugger output appear in this area You can choose to view either or both by clicking the new buttons that appear at the top right of the area The debugger now supports multi threaded debug ging You can set breakpoints by clicking in the gutter area to the left of the editor Figure 1 13 The new debugger area no longer appears in a separate window although for convenience you may decide to launch it in one On a smaller monitor the debugging and console area can feel cramped hello i ane gt en OA GRD vy ueue Thread 1 Y BE comapple main thread inport helloAppDelegate h E ee ginplenentation hello ppDelegate E 1 _nsnore_catiback I 19 NSApplicationMain mio lt hello Glasses _helloAppDelegate m gt X applicationDidFinishLaunching Copyright c 2010 Skydancer Media Ltd ALL rights reserved ol Qsynthesize window
18. efly discussed how those differences affect the development workflow
19. f Mac Development Tools Before OS X Apple s IDE Integrated Development Environment was MPW Macintosh Programmer s Workshop As shown in Figure 1 2 MPW which is still available today was in competition with a commercial product called CodeWarrior Both CodeWarrior and MPW were expensive and many would be developers were put off by the initial start up costs Looking back at early IDEs CodeWarrior was based on the Metrowerks C compiler and environment It smoothed the tran sition from the 68k processors to the PowerPC and helped make the new PowerPC Macs a suc cess As an IDE CodeWarrior provided complete support for the PowerPC architecture MPW took longer to catch up with Apple s own new hardware CodeWarrior also compiled code more quickly than MPW and created faster and more efficient binaries Figure 1 2 Tr CATO LS INTLOCUCING ACOGE 4 The MPW IDE is available on Apple s FTP site and users of antique Macs can download and use it ane afe Gino developer appie com tools mpw tools c 3 Developer Log In Not a Member Macintosh Programmer s Workshop Search Q Advanced Search Support Macintosh Programmer s Workshop Quick Clicks MPW FAQ MPW Command Reterance Updated Components About NPW ARo Support Campers FTP Sno Ratesence Books Folease Noes Standards Suppon ADC Resources Debuggers Dovobomam Kis Documentation Sample Code Start Mac OS Program
20. gs and errors after each build The toolbar has been simplified Only build run and stop buttons are available eC CTCL 1 INTLOGCUCING XAcode 4 In the first release of Xcode 4 it s no longer possible to customize this area with your own selec tion of build run stop clean options as it was in Xcode 3 Working with tabs Xcode 4 introduces tabs editor sub windows that work like the tabs in a browser allowing single click switching between selected files as shown in Figure 1 4 Tabs replace the file list that appeared above the editor pane in Xcode 3 The file list was an inefficient way to select files for editing With tabs you can add your choice of files to the tab bar as you work and then save the tab bar with the project You can also delete files from the tab bar when you are no longer working on them Figure 1 4 The new tab bar replaces the project file list and appears under the main toolbar near the top of the Xcode 4 window gt Bana Casses gt i teem id initWithNibNane NSStrin dle nibBundledrnil if self super initwit bNamedrNil inibBundledrNit i 4 Custom initialization return self af fx Implenent loadView to create a view hierarchy progranmatically without using a nib void loadView a J4 Implenent viewDidLoad to do additional setup after loading the view typically from a nib void viewDidload super view idLond of Ie Override to allow orienta
21. idened the developer base but also made Xcode more difficult to download The Mac version was around 800GB The combined version is typically around 3GB Figure 1 3 The Xcode 3 IDE was productive but limited by obvious UI inefficiencies such as poor support for editing multiple files simultaneously ane m RootViewController m ShareKit Groups amp Files 1 FileName Code g A o Y BS Sharekit S e ulwebview SHK m 60K gt Classes E ulwebview SHK n j Y DJ Other Sources E SHXViewControtlerWrapper m 61K ii Sharekit_Prefix peh LE SHXViewControtlerWrapper h m main W SHKTwitterForm m 114k w gt D Resources i SHKTwitterFoem h Y D Resources iPad w SHKTWwitter mn 124K L E Mainwindow iPad xib E stixTwitter h gt YD Frameworks E SHKTumbir m 137K r gt UiKit framework a gt A RootViewController m 630 keyboardwiliHide Colts Oia P K Foundation framework votd fintshemail ry P E CoreGraphics framework a gt MessageUl framework thisAppDelegate UIApplication sharedApplication delegate gt E Security framework gt K SystemConfiguration framework theURL NSURL URLWithString theTextView text i Products item SHKItem URL theURL title thisAppDelegate 1likeString F CA uSha app self shortenURL v ore if MFMessageComposeViewController camSendText D Executabies nailController MFMailComposeViewCantroller alloc init F YA Find Results NSLog mailCont
22. ierarchy programmatically without using a nib void loadView void viewDidLoad a super viewDidLoad ofa self view TangoView thisTangoViews a M With the vertical split view and Assistant you no longer need to manually switch between counterparts or to work with the less efficient horizontal split view available in Xcode 3 This feature is one of the most useful timesavers in Xcode 4 You also can manually a select a coun terpart or other file using a new contextual right click menu as shown in Figure 1 9 Figure 1 9 You can change the behavior of Assistant to select a specific type of counterpart file which can include an object s superclass as well as its headers and includes This is useful for newcomers who may not be aware that Cocoa and other OS X headers are available in Xcode and can be used as a reference Welcome to Xcode 4 O Manual Project G8 Counterparts D Ukit framework D Foundaton framework gt O CoreGraphics framework Products Override point for customization after app launch window addSubview viewController view window makeKeyAndVisible return YES _ Tango L 1 target 105 Device SDK 4 1 TangoAppDelegate m Y C Classes ds Teno ae TangoAppDelegate h Created by Richard Mentk on 28 84 2010 i TangoAppDelegate m Copyright Skydancer Media 2010 All rights 9 mnctude
23. le This feature was removed in the final release It was a very useful feature so it may return in future updates Symbols still appear in the navigation bar in a separate menu much as they did in Xcode 3 You also can select files in the traditional way using Xcode 4 s version of the Groups amp Files pane which is now called the Project navigator But the navigation bar is very much faster As shown in Figure 1 7 it includes a separate menu that lists other relevant items including header files includes related classes and categories Click the boxes icon to the left of the left pointing arrow to view this menu Figure 1 7 At the left of the navigation bar a separate menu shows files and items that are more loosely related to the currently selected file ane Dx S im x4VI aa vewOidunioad G Recant Files p initializer Override to perforn setup thet is required before the view is loaded za Sne NSString nibNameOrNil bundle NSBundle nib undleOrNil Unsaved Files D uper initWithNibName nibNameOrNil bundle nibBundledrNill initialization Counterparts gt Superclasses gt UINavigationContralier BL lt lt proarannaticovty without using a nib Includes gt UlTableViewControfler Included By e Ff Implenent viewDidLoad to do additional setup after loading the view typically from a nib void viewDidLoad super viewDidLoad af fx f f Override to allow orientations
24. ming Ird Party Links Links W 100 nguagus source code news groups and developers won stos Macintosh Programmer s Workshop MPW is a product designed specficaly for professional Macintosh software devalopers K brings together a comprehensive collecten of Gevelopment tools designed to support C C and assembly language programmers who are writing software for Mac OS 7 x 8 x 9 x MPW is an open configurable and scriptable development environment which provides the flexibility to support complex software development projects for BBX and Power Macintosh systems Download MPW A complete fully configured MPW environment s avaiable for downloading trom the Apple Develover FTP ste The FTP site contains the same software and documentation as the Tool Chest Development Kits MPW etc folder on the August 2001 Developer CD Detailed instructions for downloading and installing MPW aro provided in the ReadMe fie See the MPW FAQ for answers to frequently asked questions about MPW Updated MPW Components MPW components that have been updated since the August 2001 Developer CD was finalzed can be downloaded from the updates page MPW and Mac OS 8 5 or later F you intone to use MPW with Mac OS 8 5 or lster please road these important notes MPW Command Reference The MPW Command Reference manual has been updated to reflect the contents of The MPW GM folder on the August 2001 Developer CD The manual is i HTML format and is a
25. n reorganized and features may be in unfamiliar locations NOTE Xcode 4 is backward compatible with Xcode 3 You can load Xcode 3 x projects and save them again and Xcode 3 should still be able to open them Naturally you can t open Xcode 4 projects in Xcode 3 In Xcode 3 floating windows could proliferate uncontrollably making them difficult to work with Xcode 4 gathers every feature into a single window with multiple work areas and panes The active areas can be shown hidden split or resized as needed Every Xcode feature includ ing Interface Builder IB and the debugger can appear in this window Features can be hidden when you re not using them Hiding and revealing features adds a small overhead but is much more efficient and productive than a chaotic mess of windows You can also create your own workspaces to save and restore complete window layouts TIP Compared to Xcode 3 Xcode 4 becomes more efficient with a larger monitor Xcode 3 often wasted screen real estate for example the right side of a code window was usually empty With Xcode 4 you can have a console debugger edi tor file list and IB open simultaneously in tiled panes With a large monitor these panes become large enough to be truly useful without scrolling resizing or switching At the top of window the toolbar area includes a new summary panel that displays project sta tus This gives progress updates as a project builds and displays a count of warnin
26. oller n TangoViewController h 7 Tango Tango Y C Classes 1 YW TangoAppDelegate h Created by Richard Mentk on 28 84 2010 df Created by Richard Wentk on 28 84 2018 E Copyright Skydancer Media 2010 All rights f Copyright Skydancer Media 2018 All rights TangoAppDelegate m reserved reserved _ TangoViewControllerh ji B TangoViewController m TangoView n inport TangoViewControtler n import lt UIMit UIKit h Fe Tan 3 import TangoView h TangoView m inplonentation TangoViewContralier TangoToken h interface TangoViewcontroller TangoToken m synthesize thisTangoView UIViewController Fr TangoView ethisTangoview gt C Other Sources NSTimer tinerl 180utlet UISegmentedControl segnenti C Resources NSTimer etiner2 _ TangoViewController xib X iMainWindaw sib int splitTine 10 property nonatomic retain IBOutlet re unsigned int splitMax 7 TangoView thisTangoView _ L Tango Info plist int timeCount Y Frameworks unsigned int splitCount gt D Ukit framework emi D Foundation framework js gt I CoreCraphics framework The designated initializer Override to C Products perform setup thet is required before the view is loaded id initWithNibNeme NSString nibNaneOrNil bundle NS undle nibBundleOrNil if self super initWithNibNeme nibNameOrNil bundle nibfundledrNil i Jf Custom initialization return self s ie Implenent load view to create a view h
27. ork ADO B 1B 1BViewController h c Archive IB Succeeded 25 02 2011 at 01 31 OLO 1B 10S Device m oz ma pe AE nOA 1ViewContraller h T BrOaAze mt lt gt De casses vor 1 review Verh u B roller Luget 10650 1 ju Jf 18ViewController n Y L Classes a wo hee ea dA Grostad Eee aoe 41 Created by Richard Wentk on 23 11 2018 i ht 2810 Sky 7 y H ma IBAppDelegate m y Sapra bi 74 Copyright 2010 Skydancer Nedia Ltd ALL rights reserved hy IBViewController h 1 E EViesControllerm Sinport lt UIKit UIKit he Ty view mpari VIKA inport IBViewController h interfa Wiewcontr M IBView m enta loselo thetebets inplenentation TBViewont roller L Other Sources a Resources gt Gal Frameworks TBAction buttonMasTay Y L Products Goroperty nonatonic ef The designated initializer Override to perforn setup that is required before the view is loaded id inmitWithNibNeme NSString nibNameOrNil bundle NSBundle nibBundledrNal if self super initWithNibNeme nibNameOrNil bundle nidBundledrNil yA ThisApp ong app eend Jf Custom initialization return self s se J Implenent loadview to create a view hierarchy progrannatically without using a nib void Loadview js Implenent viewDidLoad to do additional setup after loading the view typically fron a nib void viewDidLoad super viewDidLoad L xf j r m
28. roller L gt QI Bookmarks a gt scm mailController setSubject thisAppDelegate LikeString Project Symbols maiiController setMessageBody item customValueForKey shortURL tSHTML N amp gt B implementation Files mailController mailConposeDelegate self y gt E NiS Files hiddenFlag YES a CINSNotificationCenter defaultCenter removeObserver seif E self presentModalViewController mailController animated YES tt maitController release else infoAlert UIAlertView alloc imitWithTitle Uh oh L message You can t send email from delegate nil L cancelButtonTitte 8 otherButtonTitles nil infoAlert show infoAlert release 3 2 MA e EIG A CAUTION Strong Java support was a feature of earlier Xcode versions but that has been downgraded in recent releases Apple has moved Xcode toward supporting C family development including C Objective C C and Objective C These are now the officially supported languages for i0S and OS X development Chapter 1 Introducing Xcode 4 Alternatives to Xcode Xcode is optimized for visual development of Objective C and Cocoa projects In practice this means the Cocoa and Cocoa Touch libraries and documentation are tightly inte grated into Xcode Xcode 4 has moved toward improving support for C but there are still limits to how easily it s possible to mix Objective C Objective C and C code Apple s own librarie
29. s gt Puntine to _ TangoViewControtler 1 ciudad By E TangoViewControllerm thadSignature TangoView h inport TangoAppdelegate h Wetoder NESPIA WSEnunerator z inport TangoViewController h class Protocol TangoView m TangoToken h inplenmentation TangoAppDelegate Pobtewetttteene Basic protocols powers TangeToken m ant tnd pE synthesize window Shales synthesize viewContraller protocol NSObject TangoViewController xib BO0L LsEqual idJobject MainWindow xib BOOLJapplication UIApplication NSUIntegerJhashs re application didFinishLaunchingWithdptions __ L Tango Info plist NSDictionary launchoptions Classi superclass Y Frameworks UIApplication sharedApplication Classhclass setStatusBarHidden YES aninated NO id self NSZone zone id performSeLlector SEL aSelector id performSeLlector SEL aSelector withObject id object id performSeLlector SEL aSelectar withObject id Jabject1 withObject id object2 800L isProxy void dealloc viewController release 00L jisKindOfClass Class aClass window release 00L isMenberOFClass Class aClass super deatlocl 800L confornsToProtocol Protocol aProtocol A00L respondsToSe lector SELhaSelector Bend id retain oneway void release id autore lease NSUInteger retainCount NSString description gt i end Ka i OOF Q
30. s and example source code are a combi nation of traditional C and Objective C C and Objective C aren t widely used If you are used to developing in a different environment you may feel that Xcode works in ways that don t match your requirements If you plan to create windowed applica tions with official Apple UI elements building Objective C and Cocoa code in Xcode is likely to be your most efficient choice If you prefer to create UNIX applications with com mand line or X11 features you may prefer an alternative Although OS X is based on Darwin POSIX rather than Linux it s relatively easy to create a cross platform application core that can be extended with platform specific features It s possible to use Xcode from the command line in Terminal with your own make files build management and configu ration files If you re used to GCC and GDB on other plat forms you can run them directly from the command line bypassing most of Xcode s features Java and C C developers may prefer the free Eclipse IDE available at www eclipse org Eclipse can be extended with a C C IDE Cocoa isn t supported but Java and mixed development are For multi platform support Mono remains a popular choice Mono compiles C rather than Objective C or C but is designed to support cross platform output running similar code on Windows 0S X iPhone Android and Linux plat forms Mono also supports ASP NET web projects MonoM
31. sages static code testing support for multiple log files and better Code Completion formerly Code Sense hinting New code analysis features which offer hints about basic coding errors Improved and simplified code and symbol searches Simplified management of build targets and products Getting Started LSS S SES S S S S A Support for Schemes which offer fine control over how projects build and support dif ferent build options for different applications for example testing debugging pack aging for distribution and so on Support for Workspaces which make it easy to manage and work on multiple related projects Backward compatibility with Xcode 3 x project files Improved compiler technology Various other time saving features such as automatic unprompted file saves before a build CAUTION If you load a project made with an older version of Xcode 3 into Xcode 4 you sometimes see an error message reporting a Missing SDK You can t build the project until you fix this For details see Selecting the Base SDK near the beginning of Chapter 13 Moving from the Xcode 3 to the Xcode 4 editor The new features of the editor are described in more detail in Chapter 3 but this chapter includes a simple orientation for impatient developers who are already familiar with Xcode 3 In outline almost all the familiar features have been retained and there are some new arrivals But the UI has bee
32. ted version of iTunes and OS X So although the iPhone and iPad are simpler than a Mac and app code can be very much sim pler you should allow extra time to work for projects to support all the different possible tar gets versions and security options Xcode supports these extra possibilities but it doesn t simplify them Developing and testing a universal iOS app a single app that can run on an iPhone an iPod and an iPad remains a challenge a Chapter 1 Introducing Xcode 4 wae Figure 1 15 Create a very simple iOS app and test it in the Simulator The Simulator is best considered an educa tional rather than a production environment It s adequate for apps with simple text and graphics but it doesn t fully implement the GPS accelerometer gyroscope or other hardware options in iOS devices H helloagain helloagainViewController xib a Running helloagain on iPhone Simulator gt m helloagain iPho 3 g gt No issues helloagainViewController xib m lt Bphetioagain gt C helloagain gt IR helloagainviewConvotier xio helloagalnviewControlierxib d ko 11 40 PM Helle Apain He mS gE belloagain OS X and iOS cross development In theory you can migrate projects between platforms In practice Cocoa on OS X and Cocoa Touch on iOS have so many differences that dual platform development of a non trivial appli cation is either challenging or
33. the same version of iOS Even when they do run the same version not all hardware features and UI options are available on very device In extreme cases conditional code is required to check which device an app is running on and which version of iOS it supports Code paths may need to be selected accordingly with manual checks at runtime Apple is unlikely to simplify this process in future releases of Xcode It s more likely that the iOS device range will expand and apps will need to manage an ever increasing selection of screen sizes hardware features and operating systems The Xcode Simulator shown in Figure 1 15 includes separate iPhone and iPad testing options but it is suitable only for apps that don t use any of the iOS hardware features such as the GPS and the accelerometer All but the very simplest commercial apps should be tested on real hardware The extra requirements of provisioning and multi platform support can make iOS development feel challenging and complex A further complication is the need to produce high quality sup porting graphics and screen designs for maximum buyer impact in the App Store To date Apple s beta cycle for iOS has been more aggressive than for OS X and it s usual to have a new beta preview of iOS available almost as soon as the most recent version has been made public Beta development requires a parallel version of Xcode and beta firmware for every test device It may also require an upda
34. tions other than the default portrait orientation BOOL shouldAutorotateToInterfacedrientat Lon UIInterfacedrientatlon interfaceOrlentation Return YES for supported orientations return interfacedrientation UIInterfaceOrientationPortraith void didReceiveMemoryWarning 4 Releases the view if it doesn t have a superview super didReceiveNenoryWarningl Release any cached data images etc that aren t in use void viewDidUnload Release any retained subviews of the main view ff e g self myOutlet nil void dealloc super deatlocl gend TIP ne Tabs save the current cursor position so you can use them to switch quickly between different sections of the same file It s often useful to open multiple tabs that show the most significant methods or functions in a file Working with multiple windows Not every developer is enthusiastic about single window development Fortunately you can open multiple windows into a single project and select a different collection of editors and fea tures in each window A key goal is flexibility you can arrange your workspace how you want it with the features you want to see As shown in Figure 1 5 you can still create a separate floating window to edit a single file by double clicking the file Figure 1 5 In Xcode 4 you can still float individual files from a project in separate windows But there are usually more efficient ways to w
35. tlet or Outlet Collection property nonatonic retain I30utlet TangoView thisTangoview gend Exploring code and file management Xcode 4 includes two new panes at the left and the right that can be revealed or hidden as needed using a pair of buttons near the top right of the toolbar As shown in Figure 1 11 the left pane known as the navigation pane includes a simplified but familiar version of the Groups amp Files pane from Xcode 3 This pane also includes symbol lists search options and log listings The Get Info feature in Xcode 3 has been replaced by an info view in Xcode 4 As shown in Figure 1 11 you can display the filename type and location in a right pane which is known as the utilities pane This pane gathers miscellaneous information that previously appeared in vari ous floating windows For example IB s inspector panes appear here It also shows build target and localization information When you select a file the contents of this pane are updated auto matically This saves time over Xcode 3 s Get Info pop up menu feature which presented this information in a less accessible way _ s F aTTtind started Figure 1 11 New left and right panes in Xcode 4 display ancillary information and manage optional features that may not be needed while editing ane gt Tango E Tango F Identity and Type Y 1 target 105 Device SDK 4 1 7 TangoViewController h J enti ane Type __
36. valiable onine Questions The MPW FAQ has the answers to over 40 MPW related questions Qr Google NOTE Developing Xcode With the move to OS X Apple decided to retain control over the developer environment An IDE called Project Builder had been developed as part of the NeXTStep project A free copy of Project Builder was bundled with every copy of OS X In fall 2003 an updated and enhanced version was shipped and named Xcode 1 0 Early versions of MPW were famous for their error messages which included We already did this function This array has no size and that s bad and Call me paranoid but finding inside this comment makes me suspicious Later Apple IDEs reverted to more traditional messages Xcode has been updated with every major new release of OS X Xcode 2 0 shipped with OS X 10 4 Tiger It included improved documentation better support for Java and the Quartz Composer visual programming tool which is described in more detail in Appendix A Xcode 3 shipped with OS X 10 5 Leopard and introduced improved debugging tools Xcode 3 1 added support for early versions of iOS WeTLING Started Xcode 3 2 is shown in Figure 1 3 and was released with OS X 10 6 Snow Leopard Prior to this release Apple supplied separate builds of Xcode for iOS and OS X development With version 3 2 Xcode became a unified development environment that could target both platforms This w
Download Pdf Manuals
Related Search
Related Contents
Chamberlain SECURITY+ 940C User's Manual EN4950H EN4951SH クランクバス Télécharger le dossier de candidature 0DQXDO GH VHJXULGDG 7HUPLQDGRUD GH ILUPHV Programmation à destination des collèges saison FUNAI ELC320EM9 Owner's Manual AVANT-PROPOS Copyright © All rights reserved.
Failed to retrieve file