You are previewing Sams Teach Yourself Objective-C in 24 Hours.
O'Reilly logo
Sams Teach Yourself Objective-C in 24 Hours

Book Description

In just 24 sessions of one hour or less, you can master the Objective-C language, and start using it to write powerful native applications for both Macs and iOS devices! Using this book’s straightforward, step-by-step approach, you’ll get comfortable with Objective-C’s unique capabilities… make the most of its powerful implementation of objects and messaging…work effectively with design patterns, collections, blocks, threading, and a whole lot more. Every lesson 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 Objective-C development tasks.

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

By the Way notes present 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

  • Use Xcode to write Objective-C software more quickly and efficiently

  • Master Objective-C’s object-oriented features and techniques

  • Efficiently organize program files and projects

  • Make the most of Objective-C’s powerful messaging capabilities

  • Declare classes, instance variables, properties, methods, and actions

  • Leverage building block patterns to write more powerful code

  • Work with mutable and immutable data types

  • Organize data with collections, including dictionaries and sets

  • Manage memory the modern way, with Automatic Reference Counting (ARC)

  • Expand and extend classes with protocols, delegates, categories, and extensions

  • Apply recent language enhancements such as Associative References and Fast Enumeration

  • Create and work with portable, anonymous code blocks

  • Manage queues and threading with Grand Central Dispatch

  • Table of Contents

    1. Title Page
    2. Copyright Page
    3. Contents at a Glance
    4. Table of Contents
    5. About the Author
    6. Acknowledgments
    7. We Want to Hear from You!
    8. Reader Services
    9. Introduction
      1. Who Should Read This Book
      2. What This Book Covers
      3. Downloading the Example Files
      4. How This Book Is Organized
    10. Part I. Getting Started with Objective-C
      1. Hour 1. Overview of Objective-C
        1. Introducing Objective-C
        2. Enrolling as an Apple Developer
        3. Setting Up the Development Environment
        4. Summary
        5. Q&A
        6. Workshop
      2. Hour 2. Object-Oriented Programming with Objective-C
        1. Object-Oriented Programming in the Objective-C World
        2. Creating C with Objects
        3. Managing Inheritance in the Objective-C World
        4. Summary
        5. Q&A
        6. Workshop
      3. Hour 3. Using Object-Oriented Features in Objective-C
        1. Communicating to Methods with Messages
        2. Allocating and Initializing Objects
        3. Summary
        4. Q&A
        5. Workshop
      4. Hour 4. Organizing Projects with a Git Source Code Repository
        1. Getting to Work with Xcode
        2. Keeping Track of Your Source Code
        3. Using a Remote Repository
        4. Summary
        5. Q&A
        6. Workshop
      5. Hour 5. Using Compiler Directives
        1. Exploring Your Project
        2. Working with Compiler Directives
        3. Using Objective-C Compiler Directives
        4. Summary
        5. Q&A
        6. Workshop
    11. Part II. Working with the Objective-C Basics
      1. Hour 6. Exploring Messaging and a Testbed App
        1. Setting Up the Test App
        2. Adding a Text Field and Connecting It to Your Code
        3. Sending a Message to the Text Field
        4. Reviewing the Message Syntax
        5. Summary
        6. Q&A
        7. Workshop
      2. Hour 7. Declaring a Class in an Interface File
        1. Letting Xcode Do the Work
        2. Exploring Class Hierarchies
        3. Declaring Classes
        4. Summary
        5. Q&A
        6. Workshop
      3. Hour 8. Declaring Instance Variables in an Interface File
        1. Declaring Instance Variables and Properties
        2. Using the Class
        3. Creating an Instance Variable for CurrencyConverter with id
        4. Creating an Instance Variable for CurrencyConverter with the Class Name
        5. Creating an Instance Variable for CurrencyConverter with a Superclass Name
        6. Managing Instance Variable Scope
        7. Summary
        8. Q&A
        9. Workshop
      4. Hour 9. Declaring Properties in an Interface File
        1. Comparing Interface Variables and Properties
        2. Using Declared Properties
        3. Using Attributes
        4. Using Other Attribute Decorators
        5. Implementing Properties
        6. Summary
        7. Q&A
        8. Workshop
      5. Hour 10. Declaring Methods in an Interface File
        1. Working with Methods in a Class
        2. Reviewing Method Syntax
        3. Summary
        4. Q&A
        5. Workshop
      6. Hour 11. Declaring Actions in an Interface File
        1. Introducing Actions
        2. Comparing Actions in Mac OS X and iOS
        3. Q&A
        4. Workshop
      7. Hour 12. Routing Messages with Selectors
        1. Getting Inside Objective-C Messages
        2. Getting Inside the Objective-C Runtime
        3. Working with SEL and @selector ()
        4. Using performSelector
        5. Using NSInvocation
        6. Testing Whether an Instance Can Respond to a Selector
        7. Summary
        8. Q&A
        9. Workshop
      8. Hour 13. Building on the Foundation
        1. Exploring the Foundation Framework
        2. Foundation Classes
        3. Foundation Paradigms and Policies
        4. Summary
        5. Q&A
        6. Workshop
      9. Hour 14. Defining a Class in an Implementation File
        1. Working with a New Project
        2. Creating a New App
        3. Implementing a Method
        4. Expanding the Class with init Methods
        5. Summary
        6. Q&A
        7. Workshop
      10. Hour 15. Organizing Data with Collections
        1. Collecting Objects
        2. Getting Familiar with Property Lists
        3. Comparing the Collection Classes
        4. Creating a Collection
        5. Enumerating a Collection
        6. Testing Membership in a Collection
        7. Accessing an Object in a Collection
        8. Summary
        9. Q&A
        10. Workshop
      11. Hour 16. Managing Memory and Runtime Objects
        1. Managing Objects in Memory
        2. Managing Reference Counts Manually
        3. Managing Reference Counts with ARC
        4. Variable Qualifiers
        5. Autoreleasing Variables
        6. Summary
        7. Q&A
        8. Workshop
    12. Part III. Expanding and Extending Classes
      1. Hour 17. Extending a Class with Protocols and Delegates
        1. Exploring the Pros and Cons of Subclassing
        2. Exploring Multiple Detail Views Sample Code
        3. Looking Inside Protocols
        4. Working with Delegates
        5. Summary
        6. Q&A
        7. Workshop
      2. Hour 18. Extending a Class with Categories and Extensions
        1. Comparing Categories and Protocols
        2. Comparing Categories to Subclasses
        3. Working with Categories
        4. Using Class Extensions
        5. Working with Informal Protocols
        6. Summary
        7. Q&A
        8. Workshop
      3. Hour 19. Using Associative References and Fast Enumeration
        1. Catching Up on Objective-C 2.0 Time-Saving Features
        2. Extending Classes by Adding Instance Variables (Sort of)
        3. Using Fast Enumeration
        4. Summary
        5. Q&A
        6. Workshop
      4. Hour 20. Working with Blocks
        1. Revisiting Blocks
        2. Looking at Callbacks
        3. Introducing Blocks
        4. Exploring Blocks in Cocoa
        5. Looking Deeper into Cocoa Blocks and Memory
        6. Summary
        7. Q&A
        8. Workshop
    13. Part IV. Beyond the Basics
      1. Hour 21. Handling Exceptions
        1. Rethinking Exceptions and Errors
        2. Introducing the Exception and Error Classes
        3. Identifying an Exception
        4. Throwing an Exception
        5. Catching an Exception
        6. Summary
        7. Q&A
        8. Workshop
      2. Hour 22. Grand Central Dispatch: Using Queues and Threading
        1. Getting Started with Concurrency
        2. Introducing Queues
        3. Using Dispatch Queues
        4. Summary
        5. Q&A
        6. Workshop
      3. Hour 23. Working with the Debugger
        1. Logging Information
        2. Using Console Logs
        3. Using Smart Breakpoints
        4. Summary
        5. Q&A
        6. Workshop
      4. Hour 24. Using Instruments for Analysis
        1. Putting Instruments in Perspective
        2. Looking at Instruments
        3. Getting Started with Instruments
        4. Connecting to the iOS Simulator
        5. Summary
        6. Q&A
        7. Workshop
    14. Part V. Appendixes
      1. Appendix A. C Syntax Summary
        1. Data Types
        2. Control Structures
      2. Appendix B. Apps, Packages, and Bundles
      3. Appendix C. Archiving and Packaging Apps for Development and Testing
      4. Appendix D. Introducing Xcode 4
        1. Getting to Know Xcode
        2. Goodbye “Hello, World”
        3. Hello, App Development for Mac OS X and iOS
        4. Getting Started with Xcode
        5. Using the Navigator
        6. Using Editors
        7. Working with Assistant
        8. Getting Help in an Editor Window
        9. Using Utilities—Inspectors
        10. Using Utilities—Libraries
        11. Using the Text Editor
        12. Using the Organizer Window
    15. Index