Home > Store

Sams Teach Yourself Xcode 4 in 24 Hours

Register your product to gain access to bonus material or receive a coupon.

Sams Teach Yourself Xcode 4 in 24 Hours


  • Sorry, this book is no longer in print.
Not for Sale



  • The complete XCode 4.2 hands-on tutorial: fully covers XCode 4.2's radically revamped toolset, from Code Editor and Interface Builder to Source Control and beyond
  • Extensive advanced coverage includes frameworks, libraries, universal iOS apps, CoreData, unit tests, targets, workspaces, Dashcode, and much more
  • Step-by-step instructions, examples, quizzes, exercises, tips, and shortcuts


  • Copyright 2012
  • Edition: 1st
  • Book
  • ISBN-10: 0-672-33587-5
  • ISBN-13: 978-0-672-33587-7

In just 24 sessions of one hour or less, Sams Teach Yourself Xcode 4 in 24 Hours will help you achieve breakthrough productivity with Apple’s new Xcode 4.3+ development environment for OS X and iOS devices. Every lesson introduces new concepts and builds on what you’ve already learned, giving you a rock-solid foundation for real-world success!

Step-by-step instructions carefully walk you through the most common Xcode 4 development tasks.

Quizzes and Exercises at the end of each chapter help you test your knowledge.

By the Way notes present interesting information related to the discussion.

Did You Know? tips offer advice or show you easier ways to perform tasks.

Watch Out! cautions alert you to possible problems and give you advice on how to avoid them.

Printed in full color–figures and code appear as they do in Xcode 4.3+

  • Master the MVC design pattern at the heart of iOS and OS X development
  • Use Xcode project templates to get a head start on advanced application features
  • Efficiently use the Xcode Code Editor and get fast, contextually-aware answers with the built-in help system
  • Use iOS Storyboards to visually describe an application’s workflow
  • Get started with Core Data to simplify data management and data-driven user interfaces
  • Use frameworks and libraries to package functionality and promote time-saving code reuse
  • Use Git and Subversion source control for managing distributed projects
  • Prepare Unit tests and use the Xcode debugger to keep your projects error free
  • Package your apps for the App Store
  • Use the command-line Xcode tools for scripting and build automation



Download free code files


Author's Site

Author suggested sites: http://teachyourselfxcode.com.

Sample Content

Online Sample Chapter

Using the Xcode Source Editor

Sample Pages

Download the sample pages (includes Chapter 6 and Index)

Table of Contents

Introduction    1

HOUR 1: Xcode 4    3

Welcome to Xcode    3

The Apple Developer Programs    8

Installing the Xcode Developer Tools    11

The Nickel Tour    13

Preparing Your iOS Device (Optional)    17

Summary    20

Q&A    20

Workshop    21

HOUR 2: Just Enough Objective-C and Cocoa    23

Object-Oriented Programming and Objective-C    23

What Is Objective-C?    25

Objective-C Programming Basics    38

Memory Management and Automatic Reference Counting    48

What Is Cocoa?    50

Cocoa Versus Cocoa Touch    51

Summary    54

Q&A    55

Workshop    55

HOUR 3: Understanding the MVC Design Pattern    57

Development, Design Patterns, and MVC    57

How Xcode Implements MVC    60

An MVC Walkthrough    64

Summary    68

Q&A    68

Workshop    69

HOUR 4: Using Xcode Templates to Create Projects    71

Available Project Types    71

The Project-Creation Process    83

You’ve Got a Project    88

Summary    91

Q&A    91

Workshop    92

HOUR 5: Managing Projects and Resources    95

Getting Your Bearings    95

Managing Project Files    99

Managing Frameworks and Libraries    108

Managing Groups    110

Managing Target Properties    111

Summary    114

Q&A    115

Workshop    115

HOUR 6: Using the Xcode Source Editor    117

Understanding Editor Basics    117

Navigating Within and Between Files    126

Using the Assistant Editor    131

Correcting Errors and Warnings in the Issue Navigator    133

Refactoring Code    135

Using Code Snippets    138

Summary    142

Q&A    142

Workshop    142

HOUR 7: Working with the Xcode 4 Documentation    145

Overview of Documentation Resources    145

Configuring the Xcode Documentation Downloads    148

Understanding the Documentation Resources    149

Using the Xcode Help Viewer    155

Using the Quick Help Assistant    158

Summary    161

Q&A    162

Workshop    162

HOUR 8: Creating User Interfaces    165

What Is Interface Builder?    165

The Anatomy of an Interface Builder File    168

Creating User Interfaces    174

Working with the IB Layout Tools    177

Customizing Interface Appearance    188

Setting Object Identities    191

Adding Custom Objects to Interface Builder    192

Summary    193

Q&A    193

Workshop    194

HOUR 9: Connecting a GUI to Code    195

Outlet, Actions, and Properties: A Review    195

Making Connections to Outlets and Actions    197

Writing Connection Code with Interface Builder    205

Summary    211

Q&A    212

Workshop    212

HOUR 10: Creating iOS Application Workflows with Storyboards    215

The Power of Storyboards    215

Storyboard Terminology    216

The Anatomy of a Multiscene Project    218

Making Advanced Segues    230

A Navigation Storyboard Example    239

Summary    248

Q&A    249

Workshop    249

HOUR 11: Building and Executing Applications    251

The Language of the Build    251

Managing Targets    257

Managing Schemes    264

Using the iOS Simulator    271

Summary    276

Q&A    277

Workshop    277

HOUR 12: Using Source Control    279

Using Xcode Snapshots    279

A Brief Introduction to Source Control Systems    283

Working with Subversion and Git Repositories    285

Managing a Project in Source Control    296

Summary    307

Q&A    308

Workshop    308

HOUR 13: Xcode-Supported Languages    311

Choosing the Right Language    312

Built-In Languages    313

Adding Support for Other Languages    322

Summary    325

Q&A    326

Workshop    326

HOUR 14: Planning for Reuse: Frameworks and Libraries    329

Understanding Frameworks    329

Deploying a Framework    348

Reusing Code from Existing C/C++ Libraries    349

Summary    352

Q&A    352

Workshop    353

HOUR 15: Putting It All Together: Building an OS X Application    355

Getting Started    356

Creating the Interface    359

Attaching Code    364

Inserting Interface Object References into the Code    369

Tying Things Together    373

Increasing Functionality with a Framework    376

Summary    395

Q&A    396

Workshop    396

HOUR 16: Building an iOS Application    399

Assessing What You Already Have    400

Building from the Template    403

Adding a Static Library Target    404

Updating Application Logic and Library Calls for iOS    414

Summary    430

Q&A    431

Workshop    432

HOUR 17: Attaching Big Data: Using Core Data in Your Applications    435

Introducing Core Data    435

Using the Xcode Core Data Model Editor    438

Binding a Data Model to a User Interface    446

Accessing Data Through Code    458

Summary    462

Q&A    463

Workshop    463

HOUR 18: Test Early, Test Often    465

Adding Unit Tests to an Existing Application    466

Implementing Tests for Existing Code    472

Accessing the Rest of an Application Through the Bundle Loader    480

Summary    483

Q&A    484

Workshop    485

HOUR 19: Getting the Bugs Out    487

Getting Started with the Debugger    488

Proactive Debugging    493

Working with Breakpoints    497

Summary    506

Q&A    506

Workshop    507

HOUR 20: Keeping Things Organized: Shared Workspaces    509

Using Workspaces    510

Creating a Workspace    515

Adding Projects to the Workspace    517

Configuring the OS X Project to Work in the Workspace    519

Configuring the iOS Project to Work in the Workspace    524

Summary    530

Q&A    531

Workshop    531

HOUR 21: Advanced: Analyzing Code with Instruments    533

The Instruments Interface    534

Using Instruments    536

Additional Runs    541

Collecting Data from Additional Instruments Simultaneously    543

Summary    545

Q&A    546

Workshop    546

HOUR 22: Managing and Provisioning iOS Devices    549

Creating an iOS Distribution Certificate    550

Creating an App ID    556

Creating a Distribution Provisioning Profile    560

Summary    563

Q&A    564

Workshop    565

HOUR 23: Distributing Your Applications    567

Finalizing Your Distribution Build    568

Configuring an iTunes Connect Application Record    576

Distributing Your Archived Application    578

Summary    583

Q&A    583

Workshop    584

HOUR 24: Xcode CLI Utilities    587

Using xcode-select    588

Using xcodebuilid    590

Using xcrun    595

Other Xcode Command-Line Tools    598

Bigger and Better Command-Line Uses    599

Summary    600

Q&A    600

Workshop    602

Index    603


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020