I started developing iPhone applications in late 2007. Between then and now, I have worked on various iPhone OS applications for different companies across the globe. As you might have already guessed, iOS is my favorite platform and Objective-C is my favorite programming language. I find that Objective-C helps programmers write clean code and iOS helps developers write user-friendly and useful applications.
I have coded in other programming languages such as Assembly (using NASM and TASM) and Delphi/Pascal for many years, and I still find myself going through disassembled Objective-C code to find out which method of doing a certain thing or accomplishing a certain result in Objective-C is better optimized on a certain device and/or operating system.
After becoming comfortable with the iOS SDK, I gradually built up a thirst to write a book about the iOS SDK, and with the help of wonderful people at OReilly, you are now reading the result of the several hundred hours that have been put into writing new material for iOS 3 and iOS 4, editing, reviewing, revising, and publishing.
So, please go ahead and start exploring the recipes. I hope youll find that they are easy to cook and digest!
Organization of This Book
In this book, we will discuss frameworks and classes that are available in iOS 3 and iOS 4. In some recipes, you will find code that runs only on iOS 4 and later; in those recipes, I note that you will need the iOS 4 SDK or later to compile the example code.
Here is a concise breakdown of the material each chapter covers:
Explains how Objective-C classes are structured and how objects can be instantiated. The chapter talks about properties and delegates as well as memory management in Objective-C. Even if you are competent in Objective-C, I strongly suggest that you go through this chapter, even if you are skimming through it, to understand the basic material that is used in the rest of the chapters.
Describes various approaches to constructing your iOS applications user interface by taking advantage of different tools the SDK provides. This chapter also introduces you to features that are only available on the iPad, such as the popover and split view controllers.
Shows how you can work with table views to create professional-looking iOS applications . Table views are very dynamic in nature, and as a result, programmers sometimes have difficulty understanding how they should work with them. By reading this chapter and having a look at and trying out the example code, you will gain the knowledge that is required to comfortably work with table views.
Describes how you should use Map Kit and Core Location APIs to develop location- aware iOS applications. First you will learn about maps, and then you will learn how to detect a devices location and tailor your maps with custom annotations. You will also learn about geocoding and reverse geocoding, as well as some of the methods of the Core Location framework, which are only available in the iOS 4 SDK and later.
Demonstrates how to use gesture recognizers, which enable your users to easily and intuitively manipulate the graphical interface of your iOS applications. In this chapter, you will learn how to use all available gesture recognizers in the iOS SDK, with working examples tested on iOS 3 and iOS 4 on different devices such as the iPhone 3GS, iPhone 4, and iPad.
Demonstrates how to download data from a URL and parse XML files. You will learn about synchronous and asynchronous connections and their pros and cons. You will also learn about caching files in memory and on disk to avoid consuming the possibly limited bandwidth of an iOS device on which your application could be running.
Provides details regarding operations, threads, and timers. Using the material in this chapter, you can develop modern multithreaded iOS applications. In addition, you will learn about operations and operation queues, and how to avoid implementing your own threads and instead let iOS do it for you.
Discusses the AV Foundation and Media Player frameworks that are available on the iOS SDK. You will learn how to play audio and video files and how to handle interruptions, such as a phone call, while the audio or video is being played on both iOS 3 and iOS 4. This chapter also explains how to record audio using an iOS devices built-in microphone(s). At the end of the chapter, you will learn how to access the iPod Library and play its media content, all from inside your application.
Explains the Address Book framework and how to retrieve contacts, groups, and their information from the Address Book database on an iOS device. The Address Book framework is composed entirely of C APIs. Because of this, many Objective-C developers find it difficult to use this framework compared to frameworks that provide an Objective-C interface. After reading this chapter and trying the examples for yourself, you will feel much more confident using the Address Book framework .
Demonstrates how you can determine the availability of front- and back-facing cameras on an iOS device. Some of the recipes in this chapter are specific to iOS 4, with the rest working on both iOS 3 and iOS 4. You will also learn how to access the Photo Library using the Assets Library framework which is available in iOS 4 and later. At the end of the chapter, you will learn about editing videos right on an iOS device using a built-in view controller.