Mac OS X Advanced Development Techniques
Total Page:16
File Type:pdf, Size:1020Kb
[ Team LiB ] • Table of Contents • Index Mac OS® X Advanced Development Techniques By Joe Zobkiw Publisher: Sams Publishing Pub Date: April 22, 2003 ISBN: 0-672-32526-8 Pages: 456 Mac OS X Advanced Development Techniques introduces intermediate to advanced developers to a wide range of topics they will not find so extensively detailed anywhere else. The book concentrates on teaching Cocoa development first, and then takes that knowledge and teaches in- depth, advanced Mac OS X development through detailed examples. Topics covered include: writing applications in Cocoa, supporting plug-in architectures, using shell scripts as startup items, understanding property lists, writing screen savers, implementing preference panes and storing global user preferences, custom color pickers, components, core and non-core services, foundations, frameworks, bundles, tools, applications and more. Source code in Objective-C, Perl, Java, shell script, and other languages are included as appropriate. These solutions are necessary when developing Mac OS X software, but many times are overlooked due to their complexities and lack of documentation and examples. The project-oriented approach of Mac OS X Advanced Development Techniques lends itself perfectly to those developers who need to learn a specific aspect of this new OS. Stand-alone examples allow them to strike a specific topic with surgical precision. Each chapter will be filled with snippets of deep, technical information that is difficult or impossible to find anywhere else. [ Team LiB ] Brought to You by Like the book? Buy it! [ Team LiB ] • Table of Contents • Index Mac OS® X Advanced Development Techniques By Joe Zobkiw Publisher: Sams Publishing Pub Date: April 22, 2003 ISBN: 0-672-32526-8 Pages: 456 Copyright Preface About the Author Acknowledgments We Want to Hear from You! Reader Services Foreword Introduction Part I: Overview Chapter 1. Introduction to Mac OS X Darwin UNIX File Systems Industry Standard Protocols Quartz OpenGL QuickTime Classic (OS 9) Carbon Cocoa Java Aqua Software Conclusion Chapter 2. Introduction to Programming in Mac OS X Programming Languages Tools Frameworks Conclusion Part II: Application Level Chapter 3. Cocoa Applications The Result The Project Try This Conclusion Chapter 4. Cocoa Plug-ins The Results The First Project: plistPlugin SearchWindowController The Second Project: MyNSBP_App and MyNSBP_Plugin A Word About Symbol Collisions Try This Conclusion Chapter 5. Carbon Plug-ins The Results The CFPlugin Project What Is a UUID? The CFPlugin Project Source Code The CFPluginCarbonApp Host Application Project The CFPluginCocoaApp Host Application Project Try This Conclusion Chapter 6. Frameworks Apple Frameworks Third-Party Frameworks The Result The Carbon Framework Project The Cocoa Framework Project The Cocoa Application Project Try This Conclusion Part III: Enhancing the System Chapter 7. System Services The Result The Project The Application Connection Try This Conclusion Chapter 8. System Preference Panes The Result The Project More NSPreferencePane Try This Conclusion Chapter 9. Status Items The Result The Project Try This Conclusion Chapter 10. Screen Effects The Result The Project Try This Conclusion Chapter 11. Color Pickers The Result The Project Try This Conclusion Part IV: Advanced Methods Chapter 12. Threads The Result The Project Serial Versus Parallel Thread Priority Thread Data Try This Conclusion Chapter 13. Terminal The Result The Project Try This Conclusion Chapter 14. XML-RPC The Result The PHP Server The PHP Client The Cocoa Client Try This Conclusion Chapter 15. SOAP The Result The PHP Server The PHP Client The Cocoa Client Try This Conclusion Chapter 16. Snippets Calling Carbon from Cocoa Drawing with QuickDraw in a Cocoa Application Displaying the Username Finding a User's Home Directory Finding Application Support Directories Display Alert Panel and Write to Log Updating the Application's Dock Image Updating the Application's Dock Menu Open a URL Get the Icon of a File Scrolling About Box Checking Network Status Checking for Modifier Keys Executing AppleScripts via URL Defaults Find Sample Localizing Your Cocoa Application CURLHandle Conclusion Chapter 17. Conclusion Part V: Appendixes Appendix A. Source Code Chapter 3—RadarWatcher Chapter 4—MyNSBP_App Chapter 4—MyNSBP_Desaturate Chapter 4—MyNSBP_RemoveColor Chapter 4—plistPlugin Chapter 5—CFPlugin Chapter 5—CFPluginCarbonApp Chapter 5—CFPluginCocoaApp Chapter 5—Shared Chapter 6—MyCarbonFramework Chapter 6—MyCocoaFramework Chapter 6—MyCocoaApp Chapter 7—MyTextService Chapter 8—MyPreferencePane Chapter 9—MyStatusItem Chapter 10—MyScreenEffect Chapter 11—MyColorPicker Chapter 12—MyThread Chapter 13—MyTerminal Chapter 14—MyXMLRPC Chapter 15—MySOAP Appendix B. Online Resources Index [ Team LiB ] [ Team LiB ] Copyright 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. 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. Credits 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 Dedication This book is dedicated to all my friends and family—with a special blessing to those we've lost. [ Team LiB ] [ Team LiB ] Preface About the Author Acknowledgments We Want to Hear from You! Reader Services Foreword [ Team LiB ] [ Team LiB ] 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. [ Team LiB ] [ Team LiB ] 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 Catherine—Go 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! [ Team LiB ] [ Team LiB ] 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 book—as 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: [email protected] Mail: Mark Taber Associate Publisher Sams Publishing 201 West 103rd Street Indianapolis, IN 46290 USA [ Team LiB ] [ Team LiB ] 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. [ Team LiB ] [ Team LiB ] 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.