Chapter 1. Here We Go Round Again

So, you're still creating iPhone applications, huh? Great! The iPhone and the App Store have been a tremendous success, fundamentally changing the way mobile applications are delivered and completely changing what people expect from their mobile phones. Since the first release of the iPhone Software Development Kit (SDK) way back in March 2008, Apple has been busily adding new functionality and improving what was already there. It's no less exciting of a platform than it was back when it was first introduced. In fact, in many ways, it's more exciting, because Apple keeps expanding the amount of functionality available to third-party developers like us.

What This Book Is

This book is a guide to help you continue down the path to creating better iPhone applications. In Beginning iPhone 3 Development (Apress, 2009), our goal was to get you past the initial learning curve, and to help you get your arms around the fundamentals of building your first iPhone applications. In this book, we're assuming you already know the basics. So, in addition to showing you how to use several of the new APIs introduced with iPhone SDK 3.0, we're also going to weave in some more advanced techniques that you'll need as your iPhone development efforts grow in size and complexity.

In Beginning iPhone 3 Development, every chapter was self-contained, each presenting its own unique project or set of projects. We'll be using a similar approach in the second half of this book, but in Chapters 2 through 7, we'll focus on a single, evolving Core Data application. Each chapter will cover a specific area of Core Data functionality as we expand the application. We'll also be strongly emphasizing techniques that will keep your application from becoming unwieldy and hard to manage as it gets larger.

What You Need to Know

This book assumes that you already have some programming knowledge and that you have a basic understanding of the iPhone SDK, either because you've worked through Beginning iPhone 3 Development or because you've gained a similar foundation from other sources. We assume that you've experimented a little with the SDK, perhaps written a small program or two on your own, and have a general feel for how Xcode and Interface Builder work.

What You Need Before You Can Begin

Before you can write software for iPhone, you need a few things. For starters, you'll need an Intel-based Macintosh running Snow Leopard (Mac OS X 10.6.2 or later). Any Macintosh computer—laptop or desktop—that has been released since 2006 should work just fine, but make sure your machine is Intel-based and is capable of running Snow Leopard.

Note

You actually can develop for the iPhone using Leopard (Mac OS X 10.5 or later), but there are many great new features in Xcode that are available only on Snow Leopard. Therefore, we highly recommend upgrading to Snow Leopard if you are using an earlier release.

This may seem obvious, but you'll also need an iPhone or iPod touch. While much of your code can be tested using the iPhone simulator, not all programs will run in the simulator. And you'll want to thoroughly test any application you create on an actual device before you ever consider releasing it to the public.

Finally, you'll need to sign up to become a Registered iPhone Developer. Apple requires this step before it will allow you to download the iPhone SDK. If you're already a Registered iPhone Developer, go ahead and download the latest and greatest iPhone development tools, and skip ahead to the next section.

If you're new to Apple's Registered iPhone Developer programs, navigate to http://developer.apple.com/iphone/, which will bring you to a page similar to that shown in Figure 1-1. Just below the iPhone Dev Center banner, on the right side of the page, you'll find links labeled Log in and Register. Click the Register link. On the page that appears, click the Continue button. Follow the sequence of instructions to use your existing Apple ID or create a new one.

Apple's iPhone Dev Center web site

Figure 1.1. Apple's iPhone Dev Center web site

At some point, as you register, you'll be given a choice of several paths, all of which will lead you to the SDK download page. The three choices are free, commercial, and enterprise. All three options give you access to the iPhone SDK and Xcode, Apple's integrated development environment (IDE). Xcode includes tools for creating and debugging source code, compiling applications, and performance-tuning the applications you've written.

The free option is, as its name implies, free. It lets you develop iPhone apps that run on a software-only iPhone simulator, but does not allow you to download those apps to your iPhone or iPod touch, nor sell your apps on Apple's App Store. In addition, some programs in this book will run only on your device, not in the simulator, which means you will not be able to run them if you choose the free solution. That said, the free solution is a fine place to start if you don't mind learning without doing for those programs that won't run in the simulator.

The other two options are to sign up for an iPhone Developer Program: either the Standard (commercial) Program or the Enterprise Program. The Standard Program costs $99. It provides a host of development tools and resources, technical support, distribution of your application via Apple's App Store, and, most important, the ability to test and debug your code on an iPhone rather than just in the simulator. The Enterprise Program, which costs $299, is designed for companies developing proprietary, in-house applications for the iPhone and iPod touch. For more details on these two programs, check out http://developer.apple.com/iphone/program/.

Note

If you are going to sign up for the Standard or Enterprise Program, you should go do it right now. It can take a while to get approved, and you'll need that approval to be able to run applications on your iPhone. Don't worry, though—the projects in the early chapters of this book will run just fine on the iPhone simulator.

Because iPhone is an always-connected mobile device that uses another company's wireless infrastructure, Apple has placed far more restrictions on iPhone developers than it ever has on Macintosh developers, who are able to write and distribute programs with absolutely no oversight or approval from Apple. Apple is not doing this to be mean, but rather to minimize the chances of people distributing malicious or poorly written programs that could degrade performance on the shared network. It may seem like a lot of hoops to jump through, but Apple has gone through quite an effort to make the process as painless as possible.

What's In this Book

As we said earlier, Chapters 2 through 7 of this book focus on Core Data, Apple's primary persistence framework. The rest of the chapters cover specific areas of functionality that are either new with iPhone SDK 3.0 or were simply too advanced to include in Beginning iPhone 3 Development.

Here is a very brief overview of the chapters that follow:

  • Chapter 2, The Anatomy of Core Data: In this chapter, we'll introduce you to Core Data. You'll learn why Core Data is a vital part of your iPhone development arsenal. We'll dissect a simple Core Data application and show you how all the individual parts of a Core Data-backed application fit together.

  • Chapter 3, A Super Start: Adding, Displaying and Deleting Data: Once you have a firm grasp on Core Data's terminology and architecture, you'll learn how to do some basic tasks, including inserting, searching for, and retrieving data.

  • Chapter 4, The Devil in the Detail View: In this chapter, you'll learn how to let your users edit and change the data stored by Core Data. We'll explore techniques for building generic, reusable views so you can leverage the same code to present different types of data.

  • Chapter 5, Preparing for Change: Migrations and Versioning: Here, we'll look at Apple tools that you can use to change your application's data model, while still allowing your users to continue using their data from previous versions of your application.

  • Chapter 6, Custom Managed Objects: To really unlock the power of Core Data, you can subclass the class used to represent specific instances of data. In this chapter, we'll show you how to use custom managed objects, as well as demonstrate some of the benefits of doing so.

  • Chapter 7, Relationships, Fetched Properties, and Expressions: In this final chapter on Core Data, we'll cover some mechanisms that allow you to expand your applications in powerful ways. We'll also refactor the application we've built in the previous chapters, so that we don't need to add new classes as we expand our data model.

  • Chapter 8, Peer-to-Peer Over Bluetooth Using GameKit: One of the coolest new features of SDK 3.0 is the GameKit framework. This framework makes it easy to create programs that communicate over Bluetooth, such as multiplayer games for the iPhone and iPod touch. We'll explore GameKit by building a simple two-player game.

  • Chapter 9, Online Play: Bonjour and Network Streams: GameKit doesn't provide the ability to make multiplayer games that work over Wi-Fi or the Internet. In this chapter, we'll expand our simple two-player game so it can also be played over non-Bluetooth networks.

  • Chapter 10, Working with Data from the Web: The iPhone is an always-connected device, so learning how to pull data from the Web or other places on the Internet can be very valuable. In this chapter, we'll look at several different techniques for interacting with web servers.

  • Chapter 11, MapKit: This chapter explores another great new piece of functionality added to the iPhone SDK with the 3.0 release, MapKit. This framework allows you to leverage Google Maps directly from your application.

  • Chapter 12, Sending Mail: In the original iPhone SDK, if your application wanted to send e-mail, it needed to launch the Mail application to do so. Now, thanks to the 3.0 version, we have the ability to send e-mail directly from our applications. We'll show you how to implement that functionality in this chapter.

  • Chapter 13, iPod Library Access: It's now possible to programmatically get access to your users' complete library of audio tracks stored on their iPhone or iPod touch. In this chapter, we'll look at the various techniques used to find, retrieve, and play music and other audio tracks.

  • Chapter 14, Keeping Your Interface Responsive: Long-running programming tasks can easily bog down the iPhone's user interface. In this chapter, we'll take a look at implementing different forms of concurrency so that your application remains responsive.

  • Chapter 15, Debugging: No program is ever perfect. Bugs and defects are a natural part of the programming process. In this chapter, we'll cover various techniques for finding and fixing bugs in iPhone SDK programs.

  • Chapter 16, The Road Goes Ever On...: Sadly, every journey must come to an end. We'll wrap up this book with fond farewells and some resources we hope you'll find useful.

Are You Ready?

As we said in Beginning iPhone 3 Development, iPhone is an incredible computing platform, an ever-expanding frontier for your development pleasure. In this book, we're going to take you further down the iPhone development road, digging deeper into the SDK, touching on new and, in some cases, more advanced topics.

Read the book, and be sure to build the projects yourself—don't just copy them from the archive and run them once or twice. You'll learn most by doing. Make sure you understand what you did, and why, before moving on to the next project. Don't be afraid to make changes to the code. Experiment, tweak the code, observe the results. Rinse and repeat.

Got your iPhone SDK installed? Turn the page, put on some tunes, and let's go. Your continuing journey awaits.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.9.124