Learn C on the Mac: For OS X and iOS, Second Edition

Book description

Considered a classic by an entire generation of Mac programmers, Dave Mark's Learn C on the Mac has been updated for you to include Mac OS X Mountain Lion and the latest iOS considerations.

Learn C on the Mac: For OS X and iOS, Second Edition is perfect for beginners learning to program. It includes contemporary OS X and iOS examples! This book also does the following:

  • Provides best practices for programming newbies
  • Presents all the basics with a pragmatic, Mac OS X and iOS -flavored approach
  • Includes updated source code which is fully compatible with latest Xcode
  • After reading this book, you'll be ready to program and build apps using the C language and Objective-C will become much easier for you to learn when you're ready to pick that up.

    What you'll learn

  • Master C programming, the gateway to programming your Mac, iPhone or iPad
  • Write apps for the contemporary Mac OS X interface, the cleanest user interface around
  • Write apps for the modern iOS interface, one of the two most popular mobile platforms in the world
  • Understand variables and how to design your own data structures
  • Work with the file system
  • Connect to data sources and the Internet
  • How to handle error handling and much more
  • Who this book is for

    For anyone wanting to learn to program in Mac OS X and iOS, including developers new to the Mac and iPhone/iPad, developers new to C, or students entirely new to programming.

    Table of contents

    1. Titlepage
    2. Dedication
    3. Contents at a Glance
    4. Contents
    5. About the Authors
    6. About the Technical Reviewer
    7. Acknowledgments
    8. Introduction
    9. Chapter 1: Go Get the Tools!
      1. Installing Xcode
      2. How much is that IDE in the Window?
      3. What’s a Registered Developer?
      4. Getting the Projects
      5. Using Xcode
      6. Moving On
    10. Chapter 2: Programming Basics
      1. Programming
      2. What’s the Best Programming Language for the Mac or iOS Devices?
      3. The Programming Process
      4. What’s Next?
    11. Chapter 3: C Basics: Statements and Functions
      1. C Statements
      2. C Functions
      3. Same Program, Two Functions
      4. Doing That Again, and Again, and Again
      5. Generating Some Errors
      6. Exploring Xcode’s Built-In Manuals
      7. What’s Next?
    12. Chapter 4: C Basics: Variables and Operators
      1. An Introduction to Variables
      2. Operators
      3. Using Parentheses
      4. Operator Precedence
      5. Sample Programs
      6. Sprucing Up Your Code
      7. What’s Next?
    13. Chapter 5: Debugging
      1. What’s a Debugger?
      2. Controlling Execution
      3. Examining Variables
      4. How is a Debugger like an Iceberg?
      5. What’s Next?
    14. Chapter 6: Controlling Your Program’s Flow
      1. Flow Control
      2. Expressions
      3. Compound Expressions
      4. Statements
      5. The while Statement
      6. The for Statement
      7. The do Statement
      8. The switch Statement
      9. Breaks in Loops
      10. The continue Statement
      11. IsOdd.xcodeproj
      12. NextPrime.xcodeproj
      13. What’s Next?
    15. Chapter 7: Pointers and Parameters
      1. What Is a Pointer?
      2. Pointer Basics
      3. Function Parameters
      4. Function Return Value
      5. Putting it All Together
      6. Some Pointers on Pointers
      7. Global and Static Variables
    16. Chapter 8: More Data Types
      1. Data Types Beyond Int
      2. The Best int for the Job
      3. Working with Characters
      4. Arrays
      5. The #define Directive
      6. Text Strings
      7. What’s Next?
    17. Chapter 9: The Command Line
      1. Command Line Basics
      2. Creating a Command-Line Tool
      3. Deploying the Program
      4. Using Paths
      5. Installing a Command-Line Tool
      6. Character Input
      7. Pointer Arithmetic
      8. WordCount.xcodeproj
      9. RomanNumeral.xcodeproj
      10. One Last Word About the Command-Line Interface
      11. What’s Next?
    18. Chapter 10: Designing Your Own Data Structures
      1. Bundling Data
      2. Model A: Three Arrays
      3. Model B: The Structure Approach
      4. Passing a struct As a Parameter
      5. ParamAddress.xcodeproj
      6. struct Arrays
      7. Allocating Your Own Memory
      8. Working with Linked Lists
      9. DVDTracker.xcodeproj
      10. What’s Next?
    19. Chapter 11: Working With Files
      1. What Is a Data File?
      2. File Basics
      3. Reading a File
      4. PrintFile.xcodeproj
      5. Writing Files
      6. Fancier File Manipulation
      7. Making RomanNumeral a Better Tool
      8. File System Objects
      9. What’s Next?
    20. Chapter 12: Handling Errors
      1. Murphy’s Law
      2. Rule #1: Never Assume
      3. Rule #2: Stay Alert
      4. Rule #3: Have an Escape Plan
      5. Rule #4: Anticipate Problems
      6. Rule #5: Pick Your Battles
      7. What’s Next?
    21. Chapter 13: Advanced Topics
      1. Type Conversion
      2. Typecasting
      3. const Modifier
      4. Creating Your Own Types
      5. Enumerated Types
      6. Unions
      7. Recursion
      8. Function Pointers
      9. The Remaining Operators
      10. Getting More From The Libraries
      11. What’s Next?
    22. Chapter 14: Where Do You Go from Here?
      1. The Mac User Interface
      2. A Bit of OS X Code
      3. A Quick iOS App
      4. Just a Touch of Objective C
      5. Go Get ‘Em
    23. Appendix: Answers to Exercises
    24. Index

    Product information

    • Title: Learn C on the Mac: For OS X and iOS, Second Edition
    • Author(s): David Mark Scott Brown, James Bucanek
    • Release date: December 2012
    • Publisher(s): Apress
    • ISBN: 9781430245339