Objective-C Programming: The Big Nerd Ranch Guide

Book description

Want to write iOS apps or desktop Mac applications? This introduction to programming and the Objective-C language is your first step on the journey from someone who uses apps to someone who writes them.

Based on Big Nerd Ranch's popular Objective-C Bootcamp, Objective-C Programming: The Big Nerd Ranch Guide covers C, Objective-C, and the common programming idioms that enable developers to make the most of Apple technologies. Compatible with Xcode 5, iOS 7, and OS X Mavericks (10.9), this guide features short chapters and an engaging style to keep you motivated and moving forward. At the same time, it encourages you to think critically as a programmer.

Here are some of the topics covered:

  • Using Xcode, Apple’s documentation, and other tools

  • Programming basics: variables, loops, functions, etc.

  • Objects, classes, methods, and messages

  • Pointers, addresses, and memory management with ARC

  • Properties and Key-Value Coding (KVC)

  • Class extensions

  • Categories

  • Classes from the Foundation framework

  • Blocks

  • Delegation, target-action, and notification design patterns

  • Key-Value Observing (KVO)

  • Runtime basics

  • Table of contents

    1. Title Page
    2. Acknowledgments
    3. I. Getting Started
      1. 1. You and This Book
        1. C and Objective-C
        2. How this book works
        3. How the life of a programmer works
      2. 2. Your First Program
        1. Installing Apple’s developer tools
        2. Getting started with Xcode
        3. Where do I start writing code?
        4. How do I run my program?
        5. So, what is a program?
        6. Don’t stop
    4. II. How Programming Works
      1. 3. Variables and Types
        1. Types
        2. A program with variables
        3. Challenge
      2. 4. if/else
        1. Boolean variables
        2. When curly braces are optional
        3. else if
        4. For the more curious: conditional operators
        5. Challenge
      3. 5. Functions
        1. When should I use a function?
        2. How do I write and use a function?
        3. How functions work together
          1. Standard libraries
        4. Local variables, frames, and the stack
        5. Scope
        6. Recursion
        7. Looking at frames in the debugger
        8. return
        9. Global and static variables
        10. Challenge
      4. 6. Format Strings
        1. Using tokens
        2. Escape sequences
        3. Challenge
      5. 7. Numbers
        1. Integers
          1. Tokens for displaying integers
          2. Integer operations
            1. Integer division
            2. NSInteger and NSUInteger
            3. Operator shorthand
        2. Floating-point numbers
          1. Tokens for displaying floating-point numbers
          2. The math library
        3. Challenge
        4. A note about comments
      6. 8. Loops
        1. The while loop
        2. The for loop
        3. break
        4. continue
        5. The do-while loop
        6. Challenge: counting down
        7. Challenge: user input
      7. 9. Addresses and Pointers
        1. Getting addresses
        2. Storing addresses in pointers
        3. Getting the data at an address
        4. How many bytes?
        5. NULL
        6. Stylish pointer declarations
        7. Challenge: how much memory?
        8. Challenge: how much range?
      8. 10. Pass-By-Reference
        1. Writing pass-by-reference functions
        2. Avoid dereferencing NULL
        3. Challenge
      9. 11. Structs
        1. Challenge
      10. 12. The Heap
    5. III. Objective-C and Foundation
      1. 13. Objects
        1. Objects
          1. Classes
          2. Creating your first object
        2. Methods and messages
          1. Message sends
          2. Another message
          3. Class methods vs. instance methods
          4. Sending bad messages
            1. Capitalization counts!
            2. Objective-C naming conventions
          5. A note on terminology
        3. Challenge
      2. 14. More Messages
        1. A message with an argument
        2. Multiple arguments
        3. Nesting message sends
        4. alloc and init
        5. Sending messages to nil
        6. id
        7. Challenge
      3. 15. Objects and Memory
        1. On pointers and their values
        2. Memory management
          1. ARC
      4. 16. NSString
        1. Creating instances of NSString
        2. NSString methods
        3. Class references
        4. Other parts of the documentation
        5. Challenge: finding more NSString methods
        6. Challenge: using readline()
      5. 17. NSArray
        1. Creating arrays
        2. Accessing arrays
        3. Iterating over arrays
        4. NSMutableArray
        5. Old-style array methods
        6. Challenge: a grocery list
        7. Challenge: interesting names
      6. 18. Your First Class
        1. Accessor methods
          1. Accessor naming conventions
        2. self
        3. Multiple files
        4. Class prefixes
        5. Challenge
      7. 19. Properties
        1. Declaring properties
        2. Property attributes
        3. Dot notation
      8. 20. Inheritance
        1. Overriding methods
        2. super
        3. Inheritance hierarchy
        4. description and %@
        5. Challenge
      9. 21. Object Instance Variables and Properties
        1. Object ownership and ARC
          1. Creating the BNRAsset class
          2. Adding a to-many relationship to BNREmployee
        2. Challenge: holding portfolio
        3. Challenge: removing assets
      10. 22. Class Extensions
        1. Hiding mutability
        2. Headers and inheritance
        3. Headers and generated instance variables
        4. Challenge
      11. 23. Preventing Memory Leaks
        1. Strong reference cycles
        2. Weak references
        3. Zeroing of weak references
        4. For the More Curious: manual reference counting and ARC history
          1. Retain count rules
      12. 24. Collection Classes
        1. NSSet/NSMutableSet
        2. NSDictionary/NSMutableDictionary
        3. Immutable objects
        4. Sorting arrays
        5. Filtering
        6. Collections and ownership
        7. C primitive types
        8. Collections and nil
        9. Challenge: reading up
        10. Challenge: top holdings
        11. Challenge: sorted holdings
      13. 25. Constants
        1. Preprocessor directives
          1. #include and #import
          2. #define
        2. Global variables
        3. enum
        4. #define vs. global variables
      14. 26. Writing Files with NSString and NSData
        1. Writing an NSString to a file
        2. NSError
        3. Reading files with NSString
        4. Writing an NSData object to a file
        5. Reading an NSData from a file
        6. Finding special directories
      15. 27. Callbacks
        1. The run loop
        2. Target-action
        3. Helper objects
        4. Notifications
        5. Which to use?
        6. Callbacks and object ownership
        7. For the more curious: how selectors work
      16. 28. Blocks
        1. Using blocks
          1. Declaring a block variable
          2. Composing a block
          3. Passing in a block
          4. typedef
        2. Blocks vs. other callbacks
        3. More on blocks
          1. Return values
          2. Anonymous blocks
          3. External variables
            1. Using self in blocks
              1. Unexpectedly using self in blocks
            2. Modifying external variables
        4. Challenge: an anonymous block
        5. Challenge: using a block with NSNotificationCenter
      17. 29. Protocols
        1. Calling optional methods
      18. 30. Property Lists
        1. Challenge
    6. IV. Event-Driven Applications
      1. 31. Your First iOS Application
        1. GUI-based applications
        2. Getting started with iTahDoodle
        3. BNRAppDelegate
        4. Model-View-Controller
        5. The application delegate
        6. Setting up views
        7. Running on the iOS simulator
        8. Wiring up the button
        9. Wiring up the table view
        10. Saving and loading data
          1. Adding a C helper function
          2. Saving task data
          3. Loading task data
        11. For the more curious: what about main()?
        12. For the more curious: running iTahDoodle on a device
      2. 32. Your First Cocoa Application
        1. Getting started with TahDoodle
        2. Setting up views in Interface Builder
          1. Setting up the button
          2. Setting up the table view
          3. Adding autolayout constraints
        3. Making connections
          1. File’s Owner
          2. Setting the button’s target-action pair
          3. Connecting the table view
        4. Implementing NSTableViewDataSource
        5. Saving and loading data
        6. Challenge
    7. V. Advanced Objective-C
      1. 33. init
        1. Writing init methods
        2. A basic init method
          1. instancetype
          2. Using and checking the superclass initializer
        3. init methods that take arguments
        4. Using accessors
        5. Multiple initializers
        6. Deadly init methods
      2. 34. More about Properties
        1. More on property attributes
          1. Mutability
          2. Lifetime specifiers
            1. copy
            2. More about copying
          3. Advice on atomic vs. nonatomic
        2. Implementing accessor methods
      3. 35. Key-Value coding
        1. Non-object types
        2. Key paths
      4. 36. Key-Value Observing
        1. Using the context in KVO
        2. Triggering the notification explicitly
        3. Dependent properties
      5. 37. Categories
        1. Challenge
    8. VI. Advanced C
      1. 38. Bitwise Operations
        1. Bitwise-OR
        2. Bitwise-AND
        3. Other bitwise operators
          1. Exclusive-OR
          2. Complement
          3. Left-shift
          4. Right-shift
        4. Using enum to define bit masks
        5. More bytes
        6. Challenge
      2. 39. C Strings
        1. char
        2. char *
        3. String literals
        4. Converting to and from NSString
        5. Challenge
      3. 40. C Arrays
        1. Challenge
      4. 41. Running from the Command Line
        1. Command-line arguments
        2. More convenient running from the command-line
      5. 42. Switch Statements
    9. A. The Objective-C Runtime
      1. Introspection
      2. Dynamic method lookup and execution
      3. Management of classes and inheritance hierarchies
      4. How KVO works
      5. Final notes
      6. Challenge: instance variables
    10. Next Steps
    11. Index
    12. More From Big Nerd Ranch...

    Product information

    • Title: Objective-C Programming: The Big Nerd Ranch Guide
    • Author(s):
    • Release date: November 2013
    • Publisher(s): Big Nerd Ranch Guides
    • ISBN: 9780133491920