We assume that youre a reasonably capable programmer, but we dont assume youve ever developed for iOS or OS X, or used Objective-C before. We also assume that youre fairly comfortable navigating OS X as a user, and know how to use an iOS device.
Organization of This Book
In this book, well be talking about Cocoa and Cocoa Touch, the frameworks used on OS X and iOS, respectively. Along the way, well also be covering Objective-C, including its syntax and features. Pretty much every chapter contains practical exercises that you can follow along with. The early chapters cover general topics, such as setting up a development environment and coming to grips with the Objective-C language, while later chapters cover specific features of Cocoa and Cocoa Touch.
Here is a concise breakdown of the material each chapter covers:
This chapter introduces Cocoa and Cocoa touch, the frameworks used on OS X and iOS. It introduces Xcode, the IDE that youll be using while coding for these platforms. This chapter also covers the Apple Developer Programs, which are necessary if you want to distribute software on the Mac or iTunes App Stores.
This chapter covers object-oriented programming, the programming paradigm used in Objective-C, as well as how Objective-C implements object-oriented programming. This chapter also covers memory management in Cocoa and Cocoa touch, which is one of the most important things to understand when developing for the Mac and for iOS.
This chapter introduces the Foundation framework, which provides the basic data types (like strings, arrays, and dictionaries). This chapter also discusses the underlying design patterns on which much of Cocoa and Cocoa Touch are based.
This chapter discusses how applications are assembled and operate on Mac and iOS devices. In this chapter, well talk about the application life cycle on both platforms, as well as how sandboxing affects application access to data and resources.
This chapter demonstrates how user interfaces are loaded and presented to the user. This chapter introduces one of the most powerful concepts provided by Cocoa: nibs , which are predesigned and preconfigured user interfaces, and which can be directly connected to your code. This chapter also discusses Core Animation, the animation system used on OS X and iOS, and UIDynamics, used for adding physics to your user interfaces.
This chapter introduces blocks, which are an incredibly flexible and useful addition that Objective-C introduces to the C language. Blocks are functions that can be stored in variables and passed around like values. This makes things like callbacks very simple to implement. This chapter also introduces operation queues, which are a straightforward way to work with concurrency without having to deal with threads.
In this chapter, youll learn about the drawing system used on both OS X and iOS, as well as how to draw custom graphics. SpriteKit, the retina display, as well as how view geometry works are also covered.
This chapter covers audio and video playback using AVFoundation, the audio and video engine. Youll also learn how use speech synthesis, access the iOS photo library, and get access to the users photos.
This chapter covers a range of data storage options available on OS X and iOS. Key-Value Coding and Key-Value Observing, preferences, notifications, and filesystem access are all covered. In addition, youll learn how to make security-scoped bookmarks, which allow sandboxed apps to retain access to locations that the user has granted your apps permission to use.
This chapter covers Cocoa Bindings, a tremendously powerful system that allows you to connect your applications user interface to an applications data without the need for intermediary glue code.
This chapter covers table views (an effective way to display multiple rows of data to your user) and collection views, which allow you to display a collection of items to the user.
This chapter discusses the document systems on both iOS and OS X, which are instrumental in creating applications that work with multiple documents. Here, we discuss the differences in how the two platforms handle documents.
Cocoa and Cocoa Touch provide straightforward tools for accessing networked resources, and this chapter demonstrates how to retrieve information from the Internet while keeping the application responsive. This chapter also covers the network service discovery system, Bonjour, and multipeer connectivity.
This chapter covers a variety of technologies used to work with the physical world: Core Location, for getting access to the GPS; Core Motion, for learning about how the hardware is moving and oriented; and the printing systems on both iOS and OS X. Beacons, game controllers, and maps are also discussed.
This chapter discusses the calendaring system used on iOS and OS X, and demonstrates how to get access to the users calendar. We also discuss considerations for user privacy.
This chapter covers Instruments, the profiler and analysis tool for Mac and iOS applications. An example of a crashing application is discussed, and the cause of the crash is diagnosed and fixed using the application. Additionally, this chapter covers Xcodes built-in debugger.
This chapter discusses how applications can share text, images, and other content with various services like Twitter and Facebook, using the built-in sharing systems (which dont require your application to deal with authenticating to these services). Additionally, well cover both push notifications and local notifications, which allow your application to display information to the user without running.
Not every program you write will be an app that sits on the users home screen, and this chapter tells you how to write three different kinds of nontraditional apps: command-line tools, menu bar apps, multiscreen iOS apps, and preference panes.
This chapter covers TextKit, as well as the string localization system available on iOS and OS X. Here, we also discuss data extraction from text using the built-in Data Detectors.
This chapter discusses iCloud, the cloud data storage and syncing system provided by Apple. The functionality and requirements of iCloud are discussed, as well as demonstration apps for both OS X and iOS.