Mac OS X Advanced Development Techniques
Joe Zobkiw
Sams Publishing, 201 West 103rd Street, Indianapolis, Indiana 46290
Copyright 2003 by Sams Publishing
All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein.
International Standard Book Number: 0-672-32526-8
Library of Congress Catalog Card Number: 2002116065
Printed in the United States of America
First Printing: May 2003
Reprinted with corrections: June 2003
05 04 03 4 3 2
Trademarks
All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.
Warning and Disclaimer
Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an as is basis. The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book or from the use of the CD or programs accompanying it.
Acquisitions Editor
Katie Purdum
Development Editor
Scott Meyers
Managing Editor
Charlotte Clapp
Project Editor
Andy Beaster
Copy Editor
Rhonda Tinch-Mize
Indexer
Chris Barrick
Proofreader
Jody Larsen
Technical Editor
Mike Trent
Team Coordinator
Vanessa Evans
Media Developer
Dan Scherf
Designer
Gary Adair
Page Layout
Kelly Maish
This book is dedicated to all my friends and familywith
a special blessing to those we've lost.
About the Author
Joe Zobkiw is president of TripleSoft Inc., a software development firm located in Raleigh, NC. He has been writing software for Macintosh, UNIX, and Windows operating systems since 1986. Joe has written numerous technical articles on software development-related topics throughout his career. His experience includes writing communication, utility, and business applications for commercial and private clients. This is his second book on advanced Macintosh software development.
Acknowledgments
This is the section where I thank all the people who made it possible to write the book you are now holding. Some of them introduced me to someone, some of them worked in the trenches, and some of them didn't complain while I coded for just a few more minutes.
Love and most thanks to CatherineGo Bucs!
Thanks also to Carole McClendon and everyone at Waterside Productions; Kathryn Purdum, Scott Meyers, and everyone at Sams Publishing; Mike Trent for an excellent technical review and foreword; Everyone on the various Cocoa and Mac OS X mailing lists, chat rooms, and Web sites for keeping me in the loop; Apple Computer for designing such great hardware and software and all the folks who work hard to put it together. Also thanks to Jeff Dopko, Bob Levitus, Matt Manlove, Marty Wachter, the Emmi family, the McNair family, and the Zobkiw family.
Special note to Marty: There is a hidden chapter in this book. If you read the seventh word of every third sentence, it will tell you how to make an iTunes plug-in.
Last, but certainly not least, thanks to you for making this purchase. I know that many books are vying for your earnings, and I'm glad you chose this one. I hope you enjoy it!
We Want to Hear from You!
As the reader of this book, you are our most important critic and commentator. We value your opinion and want to know what we're doing right, what we could do better, what areas you'd like to see us publish in, and any other words of wisdom you're willing to pass our way.
You can email or write me directly to let me know what you did or didn't like about this bookas well as what we can do to make our books stronger.
Please note that I cannot help you with technical problems related to the topic of this book, and that due to the high volume of mail I receive, I might not be able to reply to every message.
When you write, please be sure to include this book's title and author as well as your name and phone or email address. I will carefully review your comments and share them with the author and editors who worked on the book.
Email:
Mail: Mark Taber
Associate Publisher
Sams Publishing
201 West 103rd Street
Indianapolis, IN 46290 USA
Reader Services
For more information about this book or others from Sams Publishing, visit our Website at www.samspublishing.com. Type the ISBN (excluding hyphens) or the title of the book in the Search box to find the book you're looking for.
Foreword
If asked to define Mac OS X in 5 words or less, I would call it a collection of new beginnings.
Some of these beginnings are obvious. With Mac OS X, Apple has delivered on its promise to bring a pre-emptive multi-tasking, memory-protected operating system to the Mac-using masses. Apple has also introduced a new user interface for Mac OS X, called Aqua, which is simple, inviting, and powerful. If you read through Apple's Web site, you will find many more examples, some even with color pictures.
But some beginnings are more profound. Many computer users are for the first time considering using an Apple computer, in part because of Mac OS X's power and ease of use. Many others are switching back to the Macintosh platform from other systems, drawn by Apple's innovative hardware and software efforts. Even IT managers are beginning to treat Mac OS X as a viable server platform.
When Mac OS X shipped in March, 2001, Apple began including developer tools with every copyfor free. This is a serious invitation to developers to explore Mac OS X from every angle: from writing applications using C, C++, Objective C, and Java; to writing web services using Perl, PHP, and Python. Mac OS X demystifies the previously complex, bringing shared libraries, plug-ins, and device drivers to the programming populace. For some, Cocoa represents the first time they really got object-oriented design. And there are those who view Mac OS X's POSIX API and tools, both from the UNIX world, as a major asset. In these ways and more Mac OS X offers something for every developer.
In the pages that follow, Joe Zobkiw will guide you through many of these stops on the Mac OS X road. Use these stops as departure-points when you begin your own projects. And once you feel comfortable, go off and explore the rest of Mac OS X's new beginnings on your own.
Michael Trent
Santa Clara, California
March 2003
Introduction
Welcome to Mac OS X: Advanced Development Techniques !
I hope you enjoy what I've put together for you here. The goal of this book is to create examples that you, as a developer, could use as jumping-off points for your own intermediate to advanced programming projects.