ebook img

Learning Cocoa with Objective-C: Developing for the Mac and iOS App Stores PDF

421 Pages·2012·5.9 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Learning Cocoa with Objective-C: Developing for the Mac and iOS App Stores

Learning Cocoa with Objective-C Paris Buttfield-Addison Jonathon Manning Published by O’Reilly Media Beijing ⋅ Cambridge ⋅ Farnham ⋅ Köln ⋅ Sebastopol ⋅ Tokyo Special Upgrade Offer If you purchased this ebook directly from oreilly.com, you have the following benefits: DRM-free ebooks—use your ebooks across devices without restrictions or limitations Multiple formats—use on your laptop, tablet, or phone Lifetime access, with free updates Dropbox syncing—your files, anywhere If you purchased this ebook from another retailer, you can upgrade your ebook to take advantage of all these benefits for just $4.99. Click here to access your ebook upgrade. Please note that upgrade offers are not available from sample content. A Note Regarding Supplemental Files Supplemental files and examples for this book can be found at http://examples.oreilly.com/0636920023203/. Please use a standard desktop web browser to access these files, as they may not be accessible from all ereader devices. All code files or examples referenced in the book will be available online. For physical books that ship with an accompanying disc, whenever possible, we’ve posted all CD/DVD content. Note that while we provide as much of the media content as we are able via free download, we are sometimes limited by licensing restrictions. Please direct any questions or concerns to [email protected]. Preface We’ve been developing for the Cocoa framework from when the Mac first supported it. Since then, we’ve seen the ecosystem of Cocoa and Objective-C development evolve from a small programmer’s niche to one of the most important and influential development environments in the world. (In fact, as 2012 closes, Objective-C is the third most popular programming language according to the TIOBE index, up from fifth most popular in 2011.) Over the years, we’ve built a lot of large, complex iOS and OS X software, shipping it to millions upon millions of users along the way. We’ve picked up a deep understanding of the toolset, frameworks, and programming language, an understanding crucial to building the best possible software for iOS and OS X. Apple constantly changes things, as the recent introduction of the svelte iPad mini and the stretched iPhone 5 show, but the knowledge necessary to bend the development tools, frameworks and languages to your will stays fairly constant. This book will give you the knowledge, confidence, and appreciation for iOS and OS X development with Cocoa, Cocoa Touch, and Objective-C. Audience We assume that you’re a reasonably capable programmer, but we don’t assume you’ve ever developed for iOS or OS X, or used Objective-C before. We also assume that you’re fairly comfortable navigating OS X as a user, and know how to use an iOS device. Organization of This Book In this book, we’ll be talking about Cocoa and Cocoa Touch, the frameworks used on OS X and iOS, respectively. Along the way, we’ll 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: Chapter 1, Cocoa Development Tools This chapter introduces Cocoa and Cocoa touch, the frameworks used on OS X and iOS. Introduces Xcode, the IDE that you’ll 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. Chapter 2, Object-Oriented Programming with Objective-C 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. Chapter 3, Foundation 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. Chapter 4, Applications on OS X and iOS This chapter discusses how applications are assembled and operate on Mac and iOS devices. In this chapter, we’ll talk about the application lifecycle on both platforms, as well as how sandboxing affects application access to data and resources. Chapter 5, Graphical User Interfaces 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. Chapter 6, Blocks and Operation Quotes 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. Chapter 7, Drawing Graphics in Views In this chapter, you’ll learn about the drawing system used on both OS X and iOS, as well as how to draw custom graphics. The retina display is also covered, as well as how view geometry works. Chapter 8, Audio and Video This chapter covers audio and video playback using AVFoundation, the audio and video engine. You’ll also learn how to access the iOS photo library and get access to the user’s photos. Chapter 9, Model Objects and Data Storage 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, you’ll 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. Chapter 10, Cocoa Bindings This chapter covers Cocoa Bindings, a tremendously powerful system that allows you to connect your application’s user interface to an application’s data, without the need for intermediary “glue code.” Chapter 11, Table Views and Collection Views 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. Chapter 12, Document-Based Applications 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. Chapter 13, Networking Cocoa and Cocoa Touch provide very 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. Chapter 14, Working with the Real World 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. Chapter 15, Event Kit This chapter discusses the calendaring system used on iOS and OS X, and demonstrates how to get access to the user’s calendar. We also discuss considerations for user privacy. Chapter 16, Instruments and the Debugger 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 Xcode’s built-in debugger. Chapter 17, Sharing and Notifications This chapter discusses how applications can share text, images, and other content with various other services like Twitter and Facebook, using the built- in sharing systems (which don’t require your application to deal with authenticating to these services). Additionally, we’ll cover both push notifications and local notifications, which allow your application to display information to the user without running. Chapter 18, Nonstandard Apps Not every program you write will be an app that sits on the user’s home screen, and this chapter tells you how to write three different kinds of non-traditional apps: command-line tools, menu bar apps, and preference panes. Chapter 19, Working with Text This chapter covers the string localization system available on iOS and OS X. Here, we discuss data extraction from text using the built-in Data Detectors. Chapter 20, iCloud 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. Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates new terms, URLs, email addresses, filenames, and file extensions. Constant width Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords. Constant width bold Shows commands or other text that should be typed literally by the user. Constant width italic Shows text that should be replaced with user-supplied values or by values determined by context. TIP This icon signifies a tip, suggestion, or general note. CAUTION This icon indicates a warning or caution. Using Code Examples This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission. We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Learning Cocoa with Objective-C by Jonathon Manning and Paris Buttfield-Addison (O’Reilly). Copyright 2013 Jonathon Manning and Paris Buttfield-Addison, 978-1-449-31849-9.” If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at [email protected]. Safari® Books Online NOTE Safari Books Online (www.safaribooksonline.com) is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business. Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training. Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders,

Description:
Get up to speed on Cocoa and Objective-C, and start developing applications on the iOS and OS X platforms. If you don’t have experience with Apple’s developer tools, no problem! From object-oriented programming to storing app data in iCloud, this book covers everything you need to build apps for
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.