1. 首页
  2. 课程学习
  3. 讲义
  4. Advanced Mac OS X Programming

Advanced Mac OS X Programming

上传者: 2019-10-05 15:13:56上传 PDF文件 15.27MB 热度 30次
Mac OS X高级编程英文版。本书共有23章:1.C and Objective-C 2.The Compiler 3. Blocks 4.Command-Line Programs 5.Exceptions, Error Handling, and Signals 6.Libraries 7.Memory 8.Debugging With GDB 9.DTrace 10.Performance Tuning 11.Files, Part 1: I/O and Permissions 12.Files, Part 2: Directories, File Systems, and LinksAdvanced Mac os X ProgrammingAdvanced Mac os X Programming: The Big NerdRanch uideby mark dalrympleCopyright o 2011 Big Nerd Ranch, IncAll rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must bebtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or byany means, electronic, mechanical, photocopying, recoring, or likewise. For information regarding permissions, contactBig nerd ranch. Inc154 Krog streetSuite 100Atlanta Ga 30307(404)478-9005http://www.bignerdranch.com/book-comments@bignerdranch.comThe 10-gallon hat with propeller logo is a trademark of Big Nerd Ranch, IncExclusive worldwide distribution of the English edition of this book byPearson Technology Group800 East 96th StreetIndianapolis, IN 46240 USAhttp://www.informit.comThe authors and publisher have taken care in writing and printing this book but make no expressed or implied warranty of anykind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages inconnection with or arising out of the use of the information or programs contained hereinAperture, Apple, AppleShare, Aqua, Bonjour, Carbon, Cocoa, Cocoa Touch, Final Cut Pro, Finder, iChat, Instruments, InterfaceBuilder, iOS, iTunes, Keychain, Leopard, Mac, Mac Os, MacBook, Objective-C, Quartz, QuickTime, Rosetta, Snow Leopard,Spotlight, Tiger, Time Machine, and Xcode are trademarks of Apple, Inc, registered in the u.s. and other countriesMany of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where thosedesignations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed withinitial capital letters or in all capitalsISBN100321706250ISBN13978-0321706256Library of Congress Control Number 2011931708First printing, august 2011DedicationFor Zoe May she grow up to be as geeky as her Weird Uncle BorkThis page intentionally left blankAcknowledgmentsThis book is based upon the experiences teaching a five-day class at The Big Nerd Ranch calledAdvanced Mac os X bootcamp. The patience and curiousity of my students has made this a morecomplete and comprehensible introduction to the plumbing that makes Mac os X a reliable, flexibleand high-performance systemSpecial thanks go to Jeremy Sherman. Jeremy stepped up and taught one of the Advanced Bootcampswhen I was unable to so. Along the way he made numerous improvements to this book and associatedcourse materials, helping to modernize and robusticize the code. Jeremy is also responsible for theexcellent under -the-hoods look at blocksIncredible thanks go to Aaron Hillegass, my co-author on the first two editions of this book. Manymoons ago Aaron took a chance on this random guy sitting in the back of a Cocoa class in ashevilleOver the years I've learned from Aaron more than I imagined possible about writing, teaching, andtreating others wellSusan loper the tireless editor, performed acts of magic on the purple prose she was givenIn preparing this book, many people reviewed the drafts and brought errors to our attention. Themost astonishing quantity of corrections over the years came from Bill Monk. It would be difficult tooverstate Bill's contributions Other technical reviewers who submitted errors or offered suggestionsJohn Vink, Juan Pablo claude, Carl-Johan Kihlborn, Mike Morton, Ajeya Vempati, Eric Peyton, ChrisRidd, Michael Simmons, David Southwick, Jeremy Wyld, Richard Wolf, Tom Van Lenten, DaveZarzycki, James Spencer, Greg Miller, Anne Halsall, Roy Lovejoy, Jonathan Saggau, Jim Magee, andRob rix. They made this book better with their useful corrections and suggestions. Any errors thatremain in this book are completely my faultI would also like to thank my wife, my "Spousal Overunit " Sharlotte De Vere, for her support, patienceand understandingThis page intentionally left blankTable of contentsForewordIntroductionMac os x: Built to evolveThis bookXVIlTypographical ConventionsXIXOnline materialsXIX1.C and objective-CCThe Compiler pipelineThe c preprocessorConst and volatile variablesVariable argument lists13Bitwise operations21Objective-C27C callbacks in Objective-C27Objective-C 2.0..29Exercises402. The Compiler43Handy Flags43Debugging44Warnings45Seeing Preprocessor Output……46Seeing the Generated Assembly Code47Compiler optimization.48GCC Extensions..49Name mangling……Testing the compiler version50The optimizer50Vectorization.51Even more Compiler flags5164-Bit Computing53The 64-bit programming modelNew Objective-C runti56Universally fat binaries56Fat binaries from the command lineFat binaries inⅩcode..60Fat binary considerationsBlocks61Block syntaxReturnⅤ alues.63Accessing encl64Changing Enclosing Scope64Block variables65Variable Capture redux66Blocks as objects67Advanced Mac os X ProgrammingWhen To Copy68Blocks in collections∴.69Block Retain Cycles6New API Using BlocksFor the more Curious: Blocks Internals7071Implementation∴71Debugging78Dumping runtime information………,79Evolving the implementation81Compiler-generated namesExercises824. Command- Line programs……···········83The Basic Program84Inside the Central Loop…………85Changing Behavior By Name………….……86Looking at the environment87Parsing the command line88getopt_long(........92User Defaults∴965. Exceptions, Error Handling, and signals…………errnosetjmp, Iongjmp∴.102Signals∴.104Handling a signal...104Blocking signals106Signal issues110Exception handling in Cocoa114Classic exception handling114tion handlil17Subclassing NSApplication to catch exceptions..............11964-bit Objective-C runtime120NSError120Logging121syslog..121ASL.123For the more curious: assertions129Static assertions130Assertmacros h130Exercises1306. Libraries13Static libraries131Shared libraries∴135But i included the header!137Frameworks137Libraries or frameworks?141Writing plug-i142Bundles in cocoa142Shared libraries and dlopen146Advanced Mac os X Programmingalopen146dymo147Bundle printer147For the more Curious: libtool150For the more curious tool151For the more curious: runtime environment variables152Exercises1547. Memory55Virtual memory155Program memory model156Memory lifetime∴159Dynamic Memory Allocation.159malloch160freeD163reallocO163calloc164alloca164Memory Ownership Issues········165Nodepools..165Debugging Memory Problems…………169Common api issues169Memory corruption170Memory leaks173Other Tools175ps175Resource limits176Miscellaneous tools180vm stat182Objective-C Garbage Collection.183How to use it183186Strong and weak references………187Finalize methods ..........................................................................................188Non Objective-C objects188External reference counts189The "new collection classes...................................... 189GC and threads189Debugging∴……...190Exercises.1908. Debugging With gDB193What Is a Debugger?.…193USing GDB from the Command Line193A sample gdb session194GDB Specifics∴206H206Stack T207Program Listings207Breakpoints.......................208
下载地址
用户评论