Objective-C Recipes: A Problem-Solution Approach

Book description

Objective-C Recipes provides a problem solution approach for dealing with key aspects of Objective-C programming, ensuring you have the indispensable reference you need to successfully execute common programming tasks. You will see how to use the unique features of the Objective-C programming language, the helpful features of the Foundation framework, and the benefits of using Objective-J as an alternative. Solutions are available for a range of problems, including:

  • Application development with Xcode

  • Working with strings, numbers and object collections

  • Using foundation classes like NSArray, NSString, NSData and more

  • Dealing with threads, multi-core processing and asynchronous processing

  • Building applications that take advantage of dates and timers and memory management

  • How to use Objective-C on other platforms

  • Objective-C Recipes is an essential reference for every Objective-C programmer, and offers solutions in a concise and easy-to-follow manner. Matthew Campbell has trained over 800 new iOS developers at the Mobile App Mastery Institute and iOS Code Camp, and here brings his expertise to offer you the ability to use and exploit Objective-C to get the most out of all of your projects.

    Table of contents

    1. Titlepage
    2. Contents at a Glance
    3. Contents
    4. About the Author
    5. About the Technical Reviewer
    6. Acknowledgments
    7. Preface
    8. Chapter 1: Application Development
      1. 1.1 Creating a Terminal Application
      2. 1.2 Writing to the Console
      3. 1.3 Creating a New Custom Class
      4. 1.4 Code Property Assessors
      5. 1.5 Code Property Assessors with @synthesize
      6. 1.6 Adding a Class Method to a Custom Class
      7. 1.7 Adding an Instance Method to a Custom Class
      8. 1.8 Extending a Class with a Category
      9. 1.9 Creating a Mac Window-Based Application from Terminal
      10. 1.10 Adding a User Control to a Mac Application
      11. 1.11 Creating a Mac Window-Based Application From Xcode
      12. 1.12 Creating an iOS Application from Xcode
      13. 1.13 Adding User Controls to an iOS Application with Target-Action
      14. 1.14 Adding User Controls to an iOS Application with Delegation
    9. Chapter 2: Working With Strings and Numbers
      1. 2.1 Creating a String Object
      2. 2.2 Reading Strings from Files on a Mac
      3. 2.3 Reading Strings from Files on iOS
      4. 2.4 Writing Strings to Files on a Mac
      5. 2.5 Writing Strings To Files On iOS
      6. 2.6 Comparing Strings
      7. 2.7 Manipulating Strings
      8. 2.8 Searching Through Strings
      9. 2.9 Localizing Strings
      10. 2.10 Converting Numbers to Strings
      11. 2.11 Converting Strings to Numbers
      12. 2.12 Formatting Numbers
    10. Chapter 3: Working with Object Collections
      1. 3.1 Creating an Array
      2. 3.2 Referencing Objects in Arrays
      3. 3.3 Obtaining the Array Count
      4. 3.4 Iterating Through an Array
      5. 3.5 Sorting an Array
      6. 3.6 Querying an Array
      7. 3.7 Manipulating Array Contents
      8. 3.8 Saving Arrays to the File System
      9. 3.9 Reading Arrays from the File System
      10. 3.10 Creating a Dictionary
      11. 3.11 Referencing Objects in Arrays
      12. 3.12 Obtaining the Dictionary Count
      13. 3.13 Iterating Through a Dictionary
      14. 3.14 Manipulating Dictionary Contents
      15. 3.15 Saving Dictionaries to the File System
      16. 3.16 Reading Dictionaries from the File System
      17. 3.17 Creating a Set
      18. 3.18 Obtaining the Set Count
      19. 3.19 Comparing Sets
      20. 3.20 Iterating Through a Set
      21. 3.21 Manipulating Set Contents
    11. Chapter 4: File System
      1. 4.1 Referencing and Using the File Manager
      2. 4.2 Getting Mac System Directory References
      3. 4.3 Getting Key iOS Directory References
      4. 4.4 Getting File Attributes
      5. 4.5 Getting the List of Files and Sub-Directories in a Directory
      6. 4.6 Managing Directories
      7. 4.7 Managing Files
      8. 4.8 Checking File Status
      9. 4.9 Changing File Attributes
      10. 4.10 Using Delegation with NSFileManager
      11. 4.11 Working with Data Using NSData
      12. 4.12 Caching Content with NSCache
    12. Chapter 5: Working With Dates, Times, and Timers
      1. 5.1 Creating a Date Object for Today
      2. 5.2 Creating Custom Dates by Component
      3. 5.3 Comparing Two Dates
      4. 5.4 Converting a String to a Date
      5. 5.5 Formatting Dates for Display
      6. 5.6 Adding and Subtracting Dates
      7. 5.7 Using a Timer to Schedule and Repeat Tasks
    13. Chapter 6: Asynchronous Processing
      1. 6.1 Running a Process in a New Thread
      2. 6.2 Communicating Between the Main Thread and a Background Thread
      3. 6.3 Locking Threads with NSLock
      4. 6.4 Locking Threads with @synchronized
      5. 6.5 Asynchronous Processing with Grand Central Dispatch (GCD)
      6. 6.6 Using Serial Queues in GCD
      7. 6.7 Implement Asynchronous Processing Using NSOperationQueue
    14. Chapter 7: Consuming Web Content
      1. 7.1 Downloading a File
      2. 7.2 Consuming a Web Service Using XML
      3. 7.3 Consuming a Web Service Using JSON
      4. 7.4 Asynchronously Consuming Web Content
    15. Chapter 8: Memory Management
      1. 8.1 Understanding Memory Management
      2. 8.2 Setting up an Application without ARC
      3. 8.3 Using Reference Counting to Manage Memory
      4. 8.4 Adding Memory Management to Your Custom Classes
      5. 8.5 Using Autorelease
      6. 8.6 Enabling Garbage Collection for Mac Applications
    16. Chapter 9: Working with Object Graphs
      1. Object-Orientated Vocabulary
      2. 9.1 Creating an Object Graph
      3. 9.2 Using Key-Value Coding
      4. 9.3 Using Key Paths in Your Object Graph Problem
      5. 9.4 Aggregating Information with Key Paths
      6. 9.5 Implementing the Observer Pattern
      7. 9.6 Inspecting Classes and Objects
      8. 9.7 Archiving Your Object Graph
    17. Chapter 10: Core Data
      1. 10.1 Adding Core Data Support to an Application
      2. 10.2 Adding an Entity Description
      3. 10.3 Adding a Managed Object to an Application
      4. 10.4 Adding a Managed Object to Core Data
      5. 10.5 Retrieving Objects from the Data Store
      6. 10.6 Posting Changes to the Data Store
      7. 10.7 Using One-To-One Relationships with Core Data
      8. 10.8 Using One-To-Many Relationships with Core Data
      9. 10.9 Managing Data Store Versioning
    18. Chapter 11: Objective-C Beyond Mac and iOS
      1. 11.1 Installing GNUstep on Windows
      2. 11.2 Objective-C Hello World on Windows
      3. 11.3 Downloading Objective-J for Web Apps
      4. 11.4 Coding a Hello World Objective-J Application
      5. 11.5 Adding a Button to an Objective-J Application
    19. Index

    Product information

    • Title: Objective-C Recipes: A Problem-Solution Approach
    • Author(s):
    • Release date: July 2012
    • Publisher(s): Apress
    • ISBN: 9781430243717