CONTENTS
Beginning Mac OS X Snow Leopard Programming
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright 2010 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-57752-3
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
Library of Congress Control Number: 2009940871
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Mac OS and Snow Leopard are trademarks or registered trademarks of Apple, Inc. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.
For Angela, Katie, and Sophie
MT
For Jennifer, Gileesa, and Rylan
DMc
CREDITS
EXECUTIVE EDITOR
Carol Long
PROJECT EDITOR
Tom Dinse
TECHNICAL EDITOR
Michael Morrison
PRODUCTION EDITOR
Rebecca Anderson
COPY EDITOR
Tricia Liebig
EDITORIAL DIRECTOR
Robyn B. Siesky
EDITORIAL MANAGER
Mary Beth Wakefield
ASSOCIATE DIRECTOR OF MARKETING
David Mayhew
PRODUCTION MANAGER
Tim Tate
VICE PRESIDENT AND EXECUTIVE GROUP PUBLISHER
Richard Swadley
VICE PRESIDENT AND EXECUTIVE PUBLISHER
Barry Pruett
ASSOCIATE PUBLISHER
Jim Minatel
PROJECT COORDINATOR, COVER
Lynsey Stanford
COVER IMAGE
Bart Coenders/istock
COVER DESIGNER
Michael E. Trent
PROOFREADERS
Kathryn Duggan
Josh Chase and Kristy Eldredge, Word One
INDEXER
Robert Swanson
ABOUT THE AUTHORS
MICHAEL TRENT has been programming in Objective-C since 1997 and programming Macs since well before that. He is a professional computer programmer and engineering manager, a technical reviewer for numerous books and magazine articles, and an occasional dabbler in Mac OS X open source projects. Currently, he is using Objective-C and Apple Computers Cocoa frameworks to build professional and consumer applications for Mac OS X. Michael holds a Bachelor of Science degree in Computer Science and a Bachelor of Arts degree in Music from Beloit College in Beloit, Wisconsin. He lives in Pittsburgh, Pennsylvania, with his family.
DREW McCORMACK has a Ph.D. in Chemical Physics and has worked much of his career as a computational scientist. Recently, he founded The Mental Faculty ( www.mentalfaculty.com ), an independent company developing applications for the Mac and iPhone in the fields of science and education. (The Mental Facultys flagship product is the flashcard study application Mental Case, which can be found at www.macflashcards.com. ) Drew is a board member and regular contributor to the MacResearch web site ( www.macresearch.org ), and is a lead on the Core Plot project ( www.code.google.com/p/core-plot ), an undertaking with the aim to develop a complete open source graphing framework for Cocoa.
ACKNOWLEDGMENTS
I WOULD LIKE TO THANK STEVE KOCHAN for his early help with this project. Thanks also to Brett Halle, Pete Steinauer, Yaniv Gur, and many others for their encouragement. Most of all, I would like to thank my wife, Angela, and my daughters, Katie and Sophie, for putting up with all the late nights.
M ICHAEL T RENT
I WISH TO THANK MY WIFE, Jennifer, and children, Gileesa and Rylan, for suffering first hand all of my wacky schemes. Thanks also to my brother and mentor Cody McCormack.
D REW McC ORMACK
INTRODUCTION
MAC OS X REPRESENTS A UNION OF many different operating system technologies. At its core you will find Unix, an operating system once reserved for high-end servers and workstations, now found on common desktop systems. With Unix comes a whole history of tools, computer languages, and runtime environments. At a higher level, you will find Cocoa, derived from the application toolkits found on NeXTSTEP and OpenStep a result of Apples merger with NeXT in 1997. In Mac OS X you will also find Carbon, a library made from elements of the original Macintosh operating system. The original Mac OS API remains for older projects, although Apple is de-emphasizing its role in Mac OS X. Other technologies have found their way into Mac OS X through the open source community, and Apple is hard at work developing new technologies unique to Mac OS X.