www.it-ebooks.info Xcode Cookbook Over 100 recipes to build your own fun and exciting iOS applications Steven F Daniel BIRMINGHAM - MUMBAI www.it-ebooks.info Xcode Cookbook Copyright © 2013 Packt Publishing All rights reserved No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews Every effort has been made in the preparation of this book to ensure the accuracy of the information presented However, the information contained in this book is sold without warranty, either express or implied Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals However, Packt Publishing cannot guarantee the accuracy of this information First published: May 2013 Production Reference: 1160513 Published by Packt Publishing Ltd Livery Place 35 Livery Street Birmingham B3 2PB, UK ISBN 978-1-84969-334-9 www.packtpub.com Cover Image by Evelyn lam (yeeyean@gmail.com) www.it-ebooks.info Credits Author Technical Editors Steven F Daniel Kaustubh Mayekar Ankita Meshram Reviewers Bob Sander-Cederlof Dave Hersey Jean-Yves Mengant Robert Wohnoutka Veena Pagare Akshata Patil Zafeer Rais Indexer Monica Ajmera Mehta Acquisition Editor Mary Nadar Graphics Ronak Dhruv Lead Technical Editor Dayan Hyames Production Coordinator Manu Joseph Project Coordinator Amey Sawant Cover Work Manu Joseph Proofreader Amy Guest www.it-ebooks.info About the Author Steven F Daniel is originally from London, England, but lives in Australia He is the owner and founder of GENIESOFT STUDIOS (http://www.geniesoftstudios com/), a software development company based in Melbourne, Victoria, that currently develops games and business applications for the iOS, Android, and Windows platforms Steven is an experienced software developer with more than 13 years of experience developing desktop and web-based applications for a number of companies including, insurance, banking and finance, oil and gas, and local and state government Steven is always interested in emerging technologies, and is a member of the SQL Server Special Interest Group (SQLSIG) and the Java Community He has been the co-founder and Chief Technology Officer (CTO) of SoftMpire Pty Ltd., a company that focused primarily on developing business applications for the iOS and Android platforms He is the author of Xcode iOS Development Beginner's Guide, iOS Essentials, and iPad Enterprise Application Development Blueprints You can check out his blog at http://geniesoftstudios.com/blog/, or follow him on twitter at http://twitter.com/GenieSoftStudio www.it-ebooks.info Acknowledgement No book is the product of just the author—he just happens to be the one with his name on the cover A number of people contributed to the success of this book, and it would take more space if I have to thank each one individually A special shout-out goes to Mary Nadar, my acquisition editor, who is the reason that this book exists Thank you Mary for believing in me and for being a wonderful guide throughout this whole process I would like to thank Amey Sawant for ensuring that I stayed on track and got my chapters in on time, and to Dayan Hyames for his brilliant suggestive approach with the chapter rewrites I would also like to extend my thanks to each of my Technical Editors for their brilliant suggestions and improvements to each chapter, as well as ensuring that we met our timeframes, and delivery for this book It has been a great privilege to work with each of you on this book Lastly, to my reviewers, thank you so much for your valued suggestions and improvements, making this book what it is I am grateful to each and every one of you Thank you also to the entire Packt Publishing team for working so diligently to help bring out a high quality product Finally, a big thank you to the engineers at Apple for creating the iPhone and the iPad, and providing developers with the tools to create fun and sophisticated applications You guys rock Finally, I'd like to thank all of my friends for their support, understanding, and encouragement during the writing process It is a privilege to know each and every one of you www.it-ebooks.info About the Reviewers Bob Sander-Cederlof has been programming for over 55 years, including 21 years at Adobe Systems During the Apple II era, as owner of S-C Software Corporation, Bob published the Apple Assembly Line newsletter for over eight years, along with software such as the S-C Macro Assembler Other interests include Christianity, the Bible, and genealogy More at http://www.txbobsc.com Dave Hersey has over 35 years of experience in Apple software development, dating back to the Apple II personal computer in 1977 In 2000, after over years in software engineering at Apple Computer, Dave started Paracoders Inc focusing on custom Mac OS X-based application and driver development In 2008, Dave's company expanded into iOS (iPhone) mobile applications, followed by Android applications soon after Some big-named clients including Paramount Home Entertainment, Lionsgate Entertainment, Seagate, Creative Labs, Monterey Bay Aquarium, and Kraft Foods Most recently, Dave's business has expanded to include additional mobile and server-side platforms as well as support services As a result, the custom software development division of Paracoders now operates as "Torchlight Apps" (http://www.torchlightapps.com) Dave was also a technical reviewer for Creating Games with cocos2d for iPhone and HTML5 Game Development with GameMaker When he's not learning new technologies, developing software, or reviewing books, Dave stays busy with his wife raising three children, three dogs, two parakeets, and about 22 ducks at last count www.it-ebooks.info Jean-Yves Mengant is the CTO at SEFAS Innovation, a French software editor He lives in France in the Paris area Jean-Yves has been in the IT industry for more than 30 years, working on many technologies and languages from Mainframes MVS to Unixes Mac IOS and Android in Assembly Java, C++, and Objective-C He has written articles for Linux Journal, C++ users Journal, and Dr Dobbs journal I would like to thank my beloved wife Martine, for supporting my work during all those years, and and my family Jean-Christophe, Aline, Mathieu, and Julie, who I love you Robert Wohnoutka is an independent software developer with over 20 years of software development experience He currently has 11 iPhone apps in the Apple app store Robert is a former Apple employee where he learned the importance of ease-of-use which is the first rule he applies in all the apps that he develops He also has over 20 years of Product Marketing experience with high-tech products where the ease-of-use aspect was his guiding light as he helped companies develop and introduce new technologies into the hands of consumers My Walks is a good example of an app Robert developed where he applied the ease-of-use principal to a GPS-based walking application This app only requires the user to tap a Start button to start the walk and the app will automatically detect the end of the user's walk should the user forget to tap the End button My Walks was featured in the Best Mobile Apps 2013 book by Jeremy J Warner and published by Portrait Health Publishing Inc Robert has also developed a version for bicycling named My Bike Rides and a version for skiing named My Ski Runs Robert has developed a number of very easy to use money management apps including EZ Adder, EZ Adder II, EZ Balances, EZ Balances II, and EZ2Compare2 He also develops customized apps including an iPhone app for his dentist's clients called Nikki Green DDS www.it-ebooks.info www.PacktPub.com Support files, eBooks, discount offers and more You might want to visit www.PacktPub.com for support files and downloads related to your book Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy Get in touch with us at service@packtpub.com for more details At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks TM http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library Here, you can access, read and search across Packt's entire library of books. Why Subscribe? ff Fully searchable across every book published by Packt ff Copy and paste, print and bookmark content ff On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books Simply use your login credentials for immediate access www.it-ebooks.info This book is dedicated to: To my favorite uncle Benjamin Jacob Daniel, for always making me smile and for inspiring me to work hard and achieve my dreams, I miss you a lot Chan Ban Guan, for the continued patience, encouragement and support, and most of all for believing in me during the writing phase of this book To my family for always believing in me and for their continued love and support To my niece Ava Madison Daniel thank you for continually bringing joy to our family To the late Steve Jobs, you will always be an inspiration and a guide towards perfection Thank you for all the amazing things you've brought to our lives May you rest in peace This book would not have been possible without your love and understanding I would like to thank you from the bottom of my heart www.it-ebooks.info Appendix The following image shows how the iPhone responds to changes on its three axes when the iPhone is tilted Under normal gravity, each of these values will be between -1 and +1 with a value of being the middle center point Moving the phone in a rapid motion will increase these values: +Y -Z -X +X +Z -Y The following table explains each of the method calls relating to the CMMotionManager class: CMMotionManager methods Description startGyroUpdates When this method is called, Core Motion kicks in and continuously updates the gyroData property of the CMMotionManager class with the latest measurement of activity startGyroUpdates ToQueue:withHandler Before calling this method, you need to ensure that you have set the update interval of the gyroUpdateInterval property When this method is called, it creates an NSOperationQueue event that queues the gyroscope event that then fires when the update interval has been reached, then calls the function and passes it the latest gyroscope data stopGyroUpdates This method turns off the Core Motion sensors and stops all updates of motion data It is a good idea to always stop gyro updates as this will save battery power 373 www.it-ebooks.info Exploring the MultiTouch Interface If you would like to find out more information about the CoreMotion class, you can refer to the Apple Developer documentation located on the link http://developer.apple.com/library/ ios/#documentation/CoreMotion/Reference/ CoreMotion_Reference/_index.html See also ff The Using the shake gesture with the touch interface recipe ff The Sensing movement with the accelerometer input recipe ff The Using Xcode to create an iOS project recipe in Chapter 1, Getting and Installing the iOS SDK Development Tools 374 www.it-ebooks.info Index Symbols +Add Attribute button 248 +Add Entity button 248 @catch, compiler directive 132 @finally compiler directive 132 @implementation directive 149 #import statement 35 @throw compiler directive 132 A accelerometer:didAccelerate method 369 accelerometer events features, using 365-369 actions adding, to interface objects 28, 29 creating, for user actions response 28 actionSheetStyle property 173 Activity Monitor option 115, 116 Activity Monitor template 124 addAnnotation method 164 Add New User option 326 addSubView method 48 AirPlay framework 215 Allocations template 124 allowsAirPlay property 218 annotation placeholders adding, to MapView control 159-166 App archiving, Xcode used 351-353 installing on iOS device, development provisioning profiles used 343-345 preparing for App Store submission, iTunes Connect used 345-350 submitting, Xcode used 351-353 AppDelegate.h interface file 302 AppDelegate.m class 253 Apple iOS development certificate, requesting from 331-334 Apple Developer Connection website URL 353 Apple Developer Tools information URL 13 Apple iOS Developer Portal URL 13 Apple TV integration video, playing with 215-218 application testing, iOS Simulator used 32-34 user interface, building 22, 23 application App IDs creating, steps for 337-340 application delegates 18 App Status, notification 329 App URL, screen field 348 argc parameter 17 argv[] parameter 17 Automation template 124 AVFoundation framework 208 B Blank option 137 Blank template 124 bluetooth used, for transferring data 273-279 Books Library user interface creating 254-257 BooksViewController class 271 btnConnect: method 278 www.it-ebooks.info btnConnect method 275 btnPressMe method 63 btnTapHere: method 65 btnTransfer: method 279 btnTransfer method 275 buttons used, for obtaining user input 51, 52 C callback method 303 camera, iOS device media, capturing with 211, 214 canMoveRowAtIndexPath: method 267 canSendTweet class 96 causeRuntimeError method 132 Certificate Signing Request (CSR) 331 CGContextAddCurveToPoint method 234 CGContextAddEllipseInRect method 237 CGContextClearRect function 232 CGContextFillPath method 237 CGContextMoveToPoint method 234 CGContextSetFillColorWithColor method 237 CGContextStrokePath method 234 CGRectMake method 237 Change Map button 146 changeMapType button 147 Choose button 115 CIFilter class 208 Clang Static Analyzer using, to examine code 41-43 CLGeoCoder class 169 clickedButtonAtIndex: method 173 CLPlacemark class about 170 CountryCode property 170 Country property 170 Name property 170 SubAdministrativeArea property 170 Sublocality property 170 Thoroughfare property 170 ZIP property 170 CLPlacemark object 170 CMAccelerometerData class 370 CMAttitude class 370 CMDeviceMotion class 370 CMGyroData class 370 CMMotionManager class 370 CMMotionManager methods startGyroUpdates method 373 startGyroUpdatesToQueue:withHandler method 373 stopGyroUpdates method 373 code examining, Clang Static Analyzer used 41-43 color effects applying, Core Image used 237-241 com.apple.developer.ubiquity-containeridentifiers, entitlements 202 com.apple.developer.ubiquity-containeridentifiers key 202 com.apple.developer.ubiquity-kvstoreidentifier, entitlements 202 commitAnimations method 70 Common Name field 331 compiler directives configuring 34-37 compile-time errors handling 134, 135 contact email address, screen field 348 contentMode property 54 contentsForType: method 198 Contract, notification 329 copyright, screen field 348 Core Data data model building 247-249 data, inserting within 261-263 files, building 249-251 Core Data framework about 246 used for deleting item, from table view 264, 265 CoreGraphics framework 208 Core Image framework about 207 used, for applying color effects 237-241 CoreLocation application building, steps for 144-147 CoreLocation framework about 141 adding, to project 142, 143 CoreMotion class Apple Developer documentation, URL 368 core motion framework 376 www.it-ebooks.info about 369, 370 CMAccelerometerData class 370 CMAttitude class 370 CMDeviceMotion class 370 CMGyroData class 370 CMMotionManager class 370 CountryCode property 170 Country property 170 curves drawing, to view 232-234 custom table view controller creating 71, 72 document state UIDocumentStateClosed 186 UIDocumentStateConflict 186 UIDocumentStateEditingDisabled 186 UIDocumentStateNormal 186 UIDocumentStateSavingError 186 documentState property 198 doGryroRotation function 372 drawRect: method 237 E D dashcode data displaying, within table view 258-261 inserting, within Core Data data model 261-263 transferring, bluetooth used 273-279 within table view, searching for 268-271 description, screen field 348 Detail pane 117 development provisioning profiles creating 340-342 using, to install App on iOS device 343-345 device orientation sensing 356-358 dialog:didFailWithError method 319 didFailWithError error Apple Developer Documentation, URL 152 didFailWithError method 314 didFinishLaunchingWithOptions method 302 didFinishSavingWithError: method 214 didSelectRowAtIndexPath: method 279 didUpdateToLocation: method 150 didUpdateToLocation method 151 disconnectFromAllPeers method 278 displayImage method 53 doAnimationStop: method 228 docContent object 198 documentChanged: method 185, 195 documents in iCloud, using 178-180 storing, within iCloud 178-180 editor area 21 e-mail messaging implementing 280-283 Energy Diagnostics template 124 entitlements com.apple.developer.ubiquity-containeridentifiers 202 com.apple.developer.ubiquity-kvstoreidentifier 202 requesting, for iCloud storage 199-202 Extended detail pane 117 F Facebook iOS application, registering with 288-292 Facebook errors within application 318-321 Facebook iOS SDK adding, to project 295-298 downloading, steps for 286, 287 types 287 Facebook Query Language (FQL) 311 Facebook social channels integrating with 315-317 FBDIalogDelegate class protocol 302 fbDidLogout method 303 FBRequestDelegate class protocol 307 FBSessionDelegate class protocol 302 fbSessionInvalidated method 303 feed dialog 317 fetchedObjects property 261 fetchRequest object 261 File Activity template 124 377 www.it-ebooks.info file version conflicts using, within iCloud 184-186 withing iCloud, detecting 184-186 fillProgressBar method 65 Financial Report, notification 329 fontWithName method 50 forKey: method 184 forSaveOperation method 198 G GameKit framework about 246 adding 246, 247 geocode address information CLPlacemark class 170 reversing 167-170 getGeocodingInformation method 168 getters method 263 GKPeerConnectionState class 279 GKPeerPickerController class 278 GKSessionDelegate object 278 GPS location current GPS location, determining 148-151 gyroscope events features, using 370-374 H handleAcceleration method 367 hasOrientationChanged method 356 HelloWorld-info.plist 18 I iCloud documents, storing 178-180 documents, using 178-180 file version conflicts, detecting 184-186 key-value data, storing 182-184 URL 205 using, iOS devices configured 204-206 iCloud-aware application building, steps for 186-198 iCloud daemon service 204 iCloud document storage about 181 using 182 iCloudExample application 177 iCloud key-value data storage 181 iCloudStatus key 184 iCloud storage APIs about 177, 181 entitlements, requesting for 199-203 iCloud document storage 181 iCloud key-value data storage 181 image displaying, within view 53, 54 selecting, from iOS device photo album 208-211 transition effects, applying 242-244 Inspection Range button 118 inspector pane 21 instruments about adding 136-139 configuring 136-139 Instruments See also Xcode Instruments Instruments pane 117 Instruments trace document toolbar Inspection Range button 118 Library button 118 Loop button 118 Pause / Resume button 118 Record / Stop button 118 Search button 118 Target button 118 Time / Run control button 118 View control 118 integrated development environments (IDEs) Interface Builder about 13 objects outlets, creating 24-27 used, for creating user interface 19-21 interface objects actions, adding 28, 29 iOS application debugging, Xcode used 39, 40 memory leaks, detecting 127-129 registering, with Facebook 288-292 runtime errors, handling 130-132 tracking 119, 120 iOS Developer portal URL 332 378 www.it-ebooks.info iOS development certificate requesting, from Apple 331-334 setting up, steps for 329-331 iOS development team setting up, steps for 324-329 iOS device accelerometer events 365-369 accelerometer events, using 365-369 App installing, development provisioning profiles used 343-345 configuring, to use iCloud 204-206 current GPS location, determining 148-151 current orientation, detecting 356-358 gyroscope events 370-374 handling 74-76 images, selecting from photo album 211 keyboard, using 59, 60 microphone, using to record sound 222-225 motion events, handling 358-361 registering, for testing 335, 336 touches, detecting with touch interface 362-365 touch events, handling 362-365 videos, selecting from photo album 211 iOS platform application, requisites iOS project creating, Xcode used 14-17 profiling 120-123 running 120-123 iOS SDK downloading 9-13 installing 9-13 iOS Simulator about 8, 13 used, for testing applications 32-34 isEqualToString method 278 isSourceTypeAvailable property 211, 214 item deleting from table view, Core Data used 264, 265 itemSelected variable 279 iTunes Connect used, for App submission to App Store 345-350 iTunes Connect User button 326 K kCLErrorDenied error 152 kCLErrorHeadingFailure error 152 kCLErrorLocationUnknown error 152 kCLErrorNetwork error 152 kCLErrorRegionMonitoringDenied error 152 kCLErrorRegionMonitoringFailure error 152 kCLErrorRegionMonitoringSetupDelayed error 152 keyboard styles about 271, 272 keyboardType property 272 keyboardType property 272 key-value data storing, in iCloud 182-184 keywords, screen field 348 L labels using, to display text 48-50 Leaks option 128 Leaks template 124 Library button 118 library pane 21 lines drawing, to view 232-234 linesCurvesView class 234 loadFromContents: method 197 locationManager:didFailWithError class 152 locationManager:didFailWithError method 152 locationManager:didUpdateToLocation method 164 logout method 308 Loop button 118 M main.m 17 MapKit class Apple Developer Documentation, URL 175 MapKit framework about 141 adding, to project 142 map views, changing between 171-175 379 www.it-ebooks.info mapView:viewForAnnotation method 163 MapViewAnnotation class 164 MapView control annotation placeholders, adding 159-162 overlay regions, adding 156-158 setShowsUserLocation property 155 using 153-155 map views changing between 171-175 MKMapTypeHybrid 174 MKMapTypeSatellite 174 MKMapTypeStandard 174 media capturing, iOS device camera used 211, 214 MediaPlayer framework used, for playing music 219-222 memory leaks detecting 127-129 MessageUI framework about 246 adding 246, 247 MFMailComposeViewController class 247, 280 microphone, iOS device using, to record sound 222-225 MKMapTypeHybrid 174 MKMapTypeSatellite 174 MKMapTypeStandard 174 motionBegan:motion:withEvent: method 362 motionCancelled:motion:withEvent: method 362 motionEnded:motion:withEvent: method 362 motionEnded method 361 motion events handling 358-361 movement sensing, with accelerometer events 365-369 moveRowAtIndexPath: method 267 moviePlaybackComplete: method 217, 218 moviePlayerController method 218 MPMoviePlayerController object 218 music playing, MediaPlayer framework used 219-222 myTwitter variable 96, 102 N Name property 170 navigation area 21 Navigation bar 117 navigationBar:setTintColor: method 283 Network Connections template 124 NSArray object variable 309 NSDictionary object 314 NSFetchedResultsController class 267 NSFileCoordinator class 178 NSFileManager class 180 NSFileVersion object 186, 198 NSManagedObject class 251 NSMutableDictionary object variable 317 NSSearchPathForDirectoriesInDomains class 225 NSTimer class 65 NSUbiquitousKeyValueStore class 183, 184 NSUserDefaults class 184 O Objective-C exception @catch compiler directive 132 @finally compiler directive 132 @throw compiler directive 132 Open Developer Tool submenu 114 Open Graph API action 307 operating system (OS) Outlet property 146 outlets creating, for Interface Builder objects 24-27 overlay regions adding, to MapView control 156-158 P Pause / Resume button 118 Payment, notification 329 peerPickerController:didConnectPeer:toSessi on: method 278 peerPickerControllerDidCancel: method 279 performFetch method 261 photo album, iOS device images, selecting from 208, 211 380 www.it-ebooks.info videos, selecting from 208, 211 photos adding, to tweet 101-105 populateBookDetails method 261, 271 populateTextBox method 56 prepareForSegue:sender method 107-110 prepareForSegue method 111 preprocessor directive See #import statement primary category, screen field 348 processQuery: method 198 progress displaying, to user 61-66 project compiling 30-32 storyboards, configuring for 80-82 R receiveData:fromPeer:inSession:context method 279 receiveData: method 282 Record / Stop button 118 reloadData method 261 request:didFailWithError: method 319 Request Certificate button 333 requests dialog 317 requestWithMethodName method 314 requestWithMethodName method 314 respondsToSelector: method 218 reverseGeocodeLocation method 169 review notes, screen field 348 rows within table view, reordering 265-267 runtime errors handling 130-133 S Save Changes button 291 ScaleAspectFill value 54 ScaleAspectFit value 54 ScaleToFill value 54 scalingMode property 218 scenes, storyboard configuring 87-91 creating 84-87 Search button 118 secondary category, screen field 348 self.tableView.editing property 267 sendDataToAllPeers: method 279 sendEmail: method 281 setAnimationCurve method 229 setShowsUserLocation property 155 setString: method 184 setters method 263 setUbiquitous:itemAtURL:destinationURL :error: method 180 shake gesture using, with touch interface 358-361 shapes drawing 235-237 filling 235-237 ShapesView class 237 shouldAutorotateToInterfaceOrientation method 18 showInView:self.view method 173 Single Sign On feature See SSO feature SLComposeViewController class 98, 99 SLComposeViewControllerResultCancelled 99 SLSLComposeViewControllerResultDone 99 social networking application project building 292-294 Facebook additional permissions, requesting 308-310 Facebook errors, within application 318-321 Facebook SDK, adding 295-298 Facebook social channels integration 315-317 framework dependencies, adding 295-298 Graph API, using to read JSON data 311-314 software development kits (SDKs) sound recording, microphone used 222-225 sourceType property 211 SSO feature about 286 implementing 298 implementing, steps for 298-303 startGyroUpdates method 373 startGyroUpdatesToQueue:withHandler method 373 381 www.it-ebooks.info startGyroUpdatesToQueue function 372 startRecord method 226 state property 279 Static Analyzer Apple developer documentation, URL 43 stopGyroUpdates method 373 storyboard adding 252, 253 Apple Developer documentation, URL 82 configuring 252, 253 configuring, for project 80-82 scenes, configuring 87-91 scenes, creating 84-87 transitions, applying 92, 93 view controllers, programmatically presenting 109-112 stringForKey: method 184 SubAdministrativeArea property 170 Sublocality property 170 Superview object 48 support URL, screen field 348 sync daemon 178 synchronize method 184 System Trace option tracking 122 System Trace template 124 Time / Run control button 118 toolbar adding, to views 66-68 touchesBegan: method 244 touch events handling 362-365 touch interface device touches, detecting 362-365 shake gesture, using 358-361 Track pane 117 Transfer button 283 transition effects applying 242-244 transitions applying, to storyboards 92, 93 preparing, to another view controller 106-109 tweet composing 94, 96 photos, adding 101-105 Twitter application creating 82 creating, steps for 83 TWTweetComposeViewController class 96, 102 TWTweetComposeViewController class instance 96 T U table view adding, to view controller 72, 73 data, displaying 258-261 data, searching for 268-271 item deleting from, Core Data used 264, 265 rows, reordering 265, 267 TableView object 74 Target button 118 text customized text, drawing 229-232 displaying 55-58 displaying, labels used 48-50 editing 55 textColor property 50 theviewDidLoad method 54 Thoroughfare property 170 Threads template 124 Time Profiler template 124 UIAccelerometer class 368 UIActionSheet class 173 UIActivityViewController class 97, 98 Apple Developer reference documentation, URL 98 UIAlertView class 198, 361 UIApplicationMainstarts function 17 UIBarButtonItem class 68 UIButton class Apple Developer documentation, URL 52 UIButton object 51 UIColor class 135 UIDevice class 358 Apple Developer documentation, URL 77, 358 UIDeviceOrientation class 358 UIDeviceOrientationDidChangeNotification class 358 382 www.it-ebooks.info UIDocument class 178 UIDocument document 180 UIDocumentSaveForCreating property 198 UIDocumentStateClosed, document state 186 UIDocumentStateConflict, document state 186 UIDocumentStateEditingDisabled, document state 186 UIDocumentStateNormal, document state 186 UIDocumentStateSavingError, document state 186 UIDocument subclass 197, 198 UIFont class Apple Developer documentation, URL 50 UIFontfontWithName method 50 UIGraphicsGetCurrentContext function 234 UIImagePickerController class 214 UIImagePickerControllerMediaType property 211 UIImagePickerControllerMediaURL method 211 UIImagePickerController object 214 UIImageView class Apple Developer documentation, URL 54 UIImageWriteToSavedPhotosAlbum method 214 UIKeyboardTypeAlphabet, keyboard type 61 UIKeyboardTypeASCIICapable, keyboard type 60 UIKeyboardType class 273 Apple Developer documentation, URL 61 UIKeyboardTypeDecimalPad, keyboard type 61 UIKeyboardTypeDefault, keyboard type 60 UIKeyboardTypeEmailAddress, keyboard type 61 UIKeyboardTypeNamePhonePad, keyboard type 61 UIKeyboardTypeNumberPad, keyboard type 60 UIKeyboardTypeNumbersAndPunctuation, keyboard type 60 UIKeyboardTypePhonePad, keyboard type 61 UIKeyboardTypeTwitter 273 UIKeyboardTypeTwitter, keyboard type 61 UIKeyboardTypeURL, keyboard type 60 UILabel object 50 UIResponder class Apple Developer documentation, URL 48, 361 UISearchBarDelegate object 269 UITableViewCellEditingStyle class 265 UITableViewCellEditingStyleDelete constant variable 265 UITableViewController class 71 UITableView object 72 UITextField class 58 UIToolbar object 68 UITouch events UITouchPhaseBegan 364 UITouchPhaseCancelled 365 UITouchPhaseEnd 365 UITouchPhaseMoved 364 UITouchPhaseStationary 365 UITouchPhaseBegan, UITouch events 364 UITouchPhaseCancelled, UITouch 365 UITouchPhaseEnd, UITouch 365 UITouchPhaseMoved, UITouch events 364 UITouchPhaseStationary, UITouch events 365 UIView animations Apple Developer documentation, URL 71 UIView class 47, 364 UIViewController class 364 UIViewController framework in Apple Developer documentation, URL 93 UIViewController subclass 109 Unique Device Identifier (UDID) 335 URLForUbiquityContainerIdentifier: method 203 URLForUbiquityContainerIdentifier method 185 user progress, displaying to 61-66 user input obtaining, buttons used 51, 52 user interface building, for application 22, 23 creating, Interface Builder used 19-21 userInterfaceIdiom property 76 Use Store with Identifier option 202 383 www.it-ebooks.info V X version number, screen field 348 videos playing, with Apple TV integration 215-218 selecting, from iOS device photo album 211 view controller about 118 table view, adding 72, 73 View Controller class implementing, steps for 305-307 ViewController class 18 view controllers, storyboard programmatically presenting 109-112 ViewController.xib 18 viewDidAppear method 18 viewDidLoad: method 227 viewDidLoad method 18, 50, 69, 134, 153, 356, 359 ViewDidLoad method 192 viewDidUnload method 18 views adding 46-48 animating 226, 229 curves, drawing 232-234 customizing 46-48 fading in 68-70 fading out 68-70 image, displaying with 53, 54 lines, drawing 232-234 toolbar, adding 66-68 viewWillAppear method 18 virtual memory faults, detecting 125, 126 Virtual Memory (VM) operations 122 Xcode about obtaining from Mac App Store, URL for 10 used, for creating iOS project 14-17 used, for debugging iOS application 39, 40 Xcode used, for archiving App 351-353 used, for submitting App 351-353 Xcode Instruments about 114-116 Activity Monitor template 124 Allocations template 124 Apple developer documentation, URL 118 Automation template 124 Blank template 124 Detail pane 117 Energy Diagnostics template 124 Extended detail pane 117 File Activity template 124 Instruments pane 117 Leaks template 124 Navigation bar 117 Network Connections template 124 System Trace template 124 Threads template 124 Time Profiler template 124 Track pane 117 Z ZIP property 170 384 www.it-ebooks.info Thank you for buying Xcode Cookbook About Packt Publishing Packt, pronounced 'packed', published its first book "Mastering phpMyAdmin for Effective MySQL Management" in April 2004 and subsequently continued to specialize in publishing highly focused books on specific technologies and solutions Our books and publications share the experiences of your fellow IT professionals in adapting and customizing today's systems, applications, and frameworks Our solution based books give you the knowledge and power to customize the software and technologies you're using to get the job done Packt books are more specific and less general than the IT books you have seen in the past Our unique business model allows us to bring you more focused information, giving you more of what you need to know, and less of what you don't Packt is a modern, yet unique publishing company, which focuses on producing quality, cutting-edge books for communities of developers, administrators, and newbies alike For more information, please visit our website: www.packtpub.com Writing for Packt We welcome all inquiries from people who are interested in authoring Book proposals should be sent to author@packtpub.com If your book idea is still at an early stage and you would like to discuss it first before writing a formal book proposal, contact us; one of our commissioning editors will get in touch with you We're not just looking for published authors; if you have strong technical skills but no writing experience, our experienced editors can help you develop a writing career, or simply get some additional reward for your expertise www.it-ebooks.info Processing 2: Creative Programming Cookbook ISBN: 978-1-849517-94-2 Paperback: 306 pages Over 90 highly-effective recipes to unleash your creativity with interactive art, graphics, computer vision, 3D, and more Explore the Processing language with a broad range of practical recipes for computational art and graphics Wide coverage of topics including interactive art, computer vision, visualization, drawing in 3D, and much more with Processing Create interactive art installations and learn to export your artwork for print, screen, Internet, and mobile devices Unity iOS Game Development Beginner's Guide ISBN: 978-1-849690-40-9 Paperback: 314 pages Develop iOS games from concept to cash flow using Unity Dive straight into game development with no previous Unity or iOS experience Work through the entire lifecycle of developing games for iOS Add multiplayer, input controls, debugging, in app and micro payments to your game Implement the different business models that will enable you to make money on iOS games Please check www.PacktPub.com for information on our titles www.it-ebooks.info LiveCode Mobile Development Beginner's Guide ISBN: 978-1-849692-48-9 Paperback: 246 pages Create fun-filled, rich apps for Android and iOS with LiveCode Create fun, interactive apps with rich media features of LiveCode Step by step instructions for creating apps and interfaces Dive headfirst into mobile application development using LiveCode backed with clear explanations enriched with ample screenshots Xcode iOS Development Beginner's Guide ISBN: 978-1-849691-30-7 Paperback: 432 pages Use the powerful Xcode suite of tools to build applications for the iPhone and iPad from scratch Learn how to use Xcode to build simple, yet powerful applications with ease Each chapter builds on what you have learned already Learn to add audio and video playback to your applications Plentiful step-by-step examples, images, and diagrams to get you up to speed in no time with helpful hints along the way Please check www.PacktPub.com for information on our titles www.it-ebooks.info ... directives 34 Debugging your iOS applications using Xcode 39 Using the Clang Static Analyzer to examine your code 41 Chapter 2: User Interfaces – Creating the UI 45 Introduction 45 Adding and... compile-time errors 1 34 Adding and configuring Instruments 136 Introduction 141 Adding the CoreLocation and MapKit frameworks 142 Building a simple CoreLocation application 144 Determining the current... Applying transition effects 242 Introduction 246 Adding the GameKit and MessageUI frameworks 246 Building the Core Data data model 247 Creating the Core Data model files 249 Adding and configuring