وبلاگ بلیان

برنامه‌نویسی پیشرفته مک او اس ایکس: راهنمای بزرگ نرد رنچ (راهنماهای بزرگ نرد رنچ)

Advanced Mac OS X Programming: The Big Nerd Ranch Guide (Big Nerd Ranch Guides)

معرفی کتاب «برنامه‌نویسی پیشرفته مک او اس ایکس: راهنمای بزرگ نرد رنچ (راهنماهای بزرگ نرد رنچ)» (با عنوان لاتین Advanced Mac OS X Programming: The Big Nerd Ranch Guide (Big Nerd Ranch Guides)) نوشتهٔ Mark Dalrymple; Aaron Hillegass، منتشرشده توسط نشر Addison-Wesley Professional در سال 2011. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.

While there are several books on programming for Mac OS X, Advanced Mac OS X Programming: The Big Nerd Ranch Guide is the only one that contains explanations of how to leverage the powerful underlying technologies. This book gets down to the real nitty-gritty. The third edition is updated for Mac OS X 10.5 and 10.6 and covers new technologies like DTrace, Instruments, Grand Central Dispatch, blocks, and NSOperation. Table of Contents 8 Advanced Mac OS X Programming 2 Foreword 18 Introduction 20 Mac OS X: Built to Evolve 20 This Book 20 Typographical Conventions 22 Online Materials 22 Chapter 1 C and Objective-C 24 C 24 The Compiler pipeline 24 The C preprocessor 25 Preprocessor symbols 25 Stringization and concatenation 27 Conditional compilation 27 Predefined symbols 28 File inclusion 31 Macro hygiene 33 Multiline macros 33 Const and volatile variables 36 Variable argument lists 36 Varargs gotchas 41 QuietLog 42 Variadic macros 43 Bitwise operations 44 Bitwise operators 44 Setting and clearing bits 47 Objective-C 50 C callbacks in Objective-C 50 Objective-C 2.0 52 Protocols 52 Class extensions 55 Fast enumeration 56 Runtime enhancements and garbage collection 60 Properties 60 Exercises 63 Chapter 2 The Compiler 66 Handy Flags 66 Debugging 67 Warnings 68 Seeing Preprocessor Output 69 Seeing the Generated Assembly Code 70 Compiler Optimization 71 GCC Extensions 72 Name Mangling 73 Testing the compiler version 73 The Optimizer 73 Vectorization 74 Even More Compiler Flags 74 64-Bit Computing 76 The 64-bit programming model 76 64-bit cleanliness 77 Should you go 64-bit? 78 New Objective-C runtime 79 Universally Fat Binaries 79 Fat binaries from the command line 79 Fat binaries in Xcode 83 Fat binary considerations 83 Chapter 3 Blocks 84 Block Syntax 85 Return Values 86 Accessing Enclosing Scope 87 Changing Enclosing Scope 87 Block Variables 88 Variable Capture Redux 89 Blocks as Objects 90 When To Copy 91 Blocks in Collections 92 Block Retain Cycles 92 New API Using Blocks 93 For the More Curious: Blocks Internals 94 Implementation 94 Block literals 95 __block variables 97 Debugging 101 gcc鈥檚 debugging information 101 clang鈥檚 debugging information 102 Dumping runtime information 102 Evolving the implementation 104 Compiler-generated names 104 Exercises 105 Chapter 4 Command-Line Programs 106 The Basic Program 107 Inside the Central Loop 108 Changing Behavior By Name 109 Looking at the Environment 110 Parsing the Command Line 111 getopt_long() 115 User Defaults 119 Chapter 5 Exceptions, Error Handling, and Signals 122 errno 122 setjmp, longjmp 125 Signals 127 Handling a signal 127 Blocking signals 129 Handling signals with sigaction() 132 Signal issues 133 Reentrancy 133 Race conditions 136 Exception Handling in Cocoa 137 Classic exception handling 137 Native exception handling 140 Subclassing NSApplication to catch exceptions 142 64-bit Objective-C runtime 143 NSError 143 Logging 144 syslog() 144 ASL 146 ASL messages 146 ASL queries 147 For the More Curious: Assertions 152 Static assertions 153 AssertMacros.h 153 Exercises 153 Chapter 6 Libraries 154 Static Libraries 154 Shared Libraries 158 But I included the header! 160 Frameworks 160 Libraries or Frameworks? 164 Writing Plug-ins 165 Bundles in Cocoa 165 Shared Libraries and dlopen 169 dlopen() 169 dlsym() 170 BundlePrinter 170 For the More Curious: libtool 173 For the More Curious: otool 174 For the More Curious: Runtime Environment Variables 175 Exercises 177 Chapter 7 Memory 178 Virtual Memory 178 Program Memory Model 179 Memory Lifetime 182 Dynamic Memory Allocation 182 malloc() 183 free() 186 realloc() 186 calloc() 187 alloca() 187 Memory Ownership Issues 188 Nodepools 188 Debugging Memory Problems 192 Common API issues 192 Memory corruption 193 MallocGuardEdges 195 MallocStackLogging and MallocStackLoggingNoCompact 195 MallocScribble 195 Guard Malloc 196 Memory leaks 196 Memory leaks in Cocoa 197 Other Tools 198 ps 198 Resource limits 199 Miscellaneous tools 203 vm_stat 205 Objective-C Garbage Collection 206 How to use it 206 How it works 209 Strong and weak references 210 Finalize methods 211 Non Objective-C objects 211 External reference counts 212 The "new" collection classes 212 GC and threads 212 Debugging 213 Exercises 213 Chapter 8聽聽Debugging With GDB 216 What Is a Debugger? 216 Using GDB from the Command Line 216 A sample GDB session 217 GDB Specifics 229 Help 229 Stack Traces 230 Program Listings 230 Breakpoints 231 Displaying Data 232 Changing Data 234 Changing Execution Flow 234 Handy Tricks 234 Debugging Techniques 236 Tracking down problems 237 Debugger techniques 238 For the More Curious: Core Files 238 For the More Curious: Stripping 241 More Advanced GDB Commands 243 Threads 243 Chapter 9聽聽DTrace 246 Overview 246 The D language 247 Scripts 248 Probes 249 Providers 250 BEGIN and END providers 250 pid provider 251 syscall provider 251 profile provider 252 proc provider 252 fbt provider 253 Actions 253 Variables 253 Scoped variables 255 Built-in variables 255 Functions 257 Arrays 257 C arrays 258 Predicates 258 Aggregates 258 Aggregate-related functions 262 Random Leftovers 262 The C preprocessor 262 Pragmas 262 Objective-C 264 Exercises 265 Chapter 10聽聽Performance Tuning 266 The End of Free Performance 266 Approaches To Performance 267 Major Causes of Performance Problems 267 Memory 268 Locality of Reference 268 Caches 270 Memory is the New I/O 271 CPU 272 Disk 272 Graphics 273 Before using any of the profiling tools 274 Command-Line Tools 274 time 275 dtruss 275 fs_usage and sc_usage 276 top 277 Stochastic profiling 278 sample 278 Precise Timing with mach_absolute_time() 279 GUI Tools 280 Activity Monitor 281 Instruments 281 Window layout 282 The Toolbar 282 Looking at memory leaks 283 More Memory: Heapshots 290 Time Profiler 294 Other Instruments 300 Memory 300 Automation 300 Power 300 Graphics 302 File System 304 System Details 304 Symbol Trace and DTrace 305 Summary 307 Exercises 307 Chapter 11聽聽Files, Part 1: I/O and Permissions 308 Unbuffered I/O 308 Opening a file 308 Writing to a file 311 Reading from a file 313 Closing files 314 Changing the read/write offset 314 Atomic operations 316 Scatter / Gather I/O 317 creat() 321 Blocking I/O 321 Buffered I/O 321 Opening files 322 Closing files 323 Text I/O 323 Binary I/O 325 Positioning 327 Formatted I/O 328 Misc Functions 329 Buffered I/O vs. Unbuffered I/O 329 Removing Files 330 Temporary Files 331 File Permissions 333 Users and groups 333 File permissions 335 Directory Permissions 341 Permission-Check Algorithms 342 For the More Curious: Memory-Mapped Files 343 Chapter 12聽聽Files, Part 2: Directories, File Systems, and Links 348 Directories 348 Creation and destruction 348 Directory iteration 348 The opendir() Family 348 Current working directory 350 Inside The File System 351 Links 353 Hard links 354 Symbolic links 354 Mac OS aliases 357 API for links 357 File Metadata 357 stat() 357 getattrlist() 362 Describing the attributes 363 Parsing the buffer 365 Metadata in batches 369 Mac OS X Specific Weirdness 373 Resource forks 373 .DS_Store 374 Disk I/O and sleep 374 For The More Curious 374 Differences between HFS+ and UFS 374 Other random calls 375 Other random programs 377 Access control lists 377 Extended attributes 378 Chapter 13聽聽NSFileManager - Cocoa and the File System 380 Making and Manipulating Paths 380 NSString path utilities 381 NSURL path utilities 382 Finding Standard Directories 382 Path utilities 383 URL utilities 384 File Metadata 386 Metadata through paths 386 Metadata through URLs 387 File Operations 390 Path operations 390 URL operations 391 Symbolic links 392 Directory Enumeration 392 Enumeration with paths 392 Enumeration with URLs 393 File References and Bookmarks 395 File references 395 Bookmarks 397 Make a File Browser 398 Create the DirEntry class 399 Edit the nib file adding NSTreeController 402 Using NSBrowser and DirEntry 407 Adding deletion 408 NSWorkspace 410 Exercises 411 Chapter 14聽聽Network Programming With Sockets 412 Addresses 412 Sockets Address Data Structures 413 IPv4 address structures 413 IPv6 address structures 414 Network Byte Order 415 Address Conversions 416 IPv4- and IPv6-compatible functions 416 IPv4-specific functions 418 Domain Name Lookup 419 Simple Network Programming 421 Server coding 421 Constructing an address 422 bind 422 listen 423 accept 423 Client Coding 427 connect 427 More Advanced Issues 431 Multiplexing connections 431 Message boundaries 433 For the More Curious: Datagrams 445 Exercises 446 Chapter 15聽聽CFRunLoop 448 CFSocket 449 CFHost 451 GUI Chatter Client 453 Runloop Chatter Server 459 The System Configuration Framework 461 Architecture 462 Basic API 462 Seeing all values 464 Creating SCFMonitor 466 For the More Curious: Run Loop Observers 471 Exercises 473 Chapter 16聽聽kqueue and FSEvents 474 kqueue() 475 Events 475 Registering and Handling Events 477 kqueues for Signal Handling 478 kqueues for Socket Monitoring 481 kqueues for File System Monitoring 482 kqueues and Runloops 485 fsevents 489 fseventsd 490 Watching Directories 490 Events 491 History 491 Visibility 492 FSEvents API 492 Creating the stream 492 Hook up to the runloop 494 The FSEvents callback 494 Miscellaneous calls 495 Example 496 Exercises 501 Chapter 17聽聽Bonjour 502 Publishing an NSNetService 503 Make chatterserver Zeroconf-compliant 503 Browsing Net Services 504 Make ChatterClient browse for servers 505 For the More Curious: TXT Records 508 Exercises 509 Chapter 18聽聽Multiprocessing 510 Process Scheduling 510 Convenience Functions 511 fork 513 Parent and Child Lifetimes 516 exec 520 Pipes 521 fork() Gotchas 525 Summary 526 Exercises 526 Chapter 19聽聽Using NSTask 528 NSProcessInfo 528 NSTask 528 NSFileHandle 529 NSPipe 530 Creating an App that Creates a New Process 530 Non-blocking reads 533 Create the header and edit the xib file 534 Edit the code 535 Exercises 537 Chapter 20聽聽Multithreading 538 Posix Threads 538 Creating threads 538 Synchronization 542 Mutexes 543 Deadlocks 545 Condition variables 546 Cocoa and Threading 557 NSThread 557 Cocoa and thread safety 558 Objective-C @synchronized blocks 558 For the More Curious: Thread Local Storage 558 For the More Curious: Read/Write Locks 559 Exercises 560 Chapter 21聽聽Operations 562 Simple-Lifetime Operations 563 NSOperationQueue 564 Threading issues 564 MandelOpper 564 Bitmap 566 BitmapView 567 CalcOperation 569 MandelOpperAppDelegate 572 NSBlockOperation 574 Complex-Lifetime Operations 576 KVO properties 577 ImageSnarfer 578 ImageCanvas 579 SnarfOperation 581 NSURLConnection delegate methods 584 ImageSnarferAppDelegate 585 Mop-up 588 Exercises 589 Chapter 22聽聽Grand Central Dispatch 592 GCD Terminology 594 Queues 594 Object-Oriented Design 596 Dispatch API 597 Queues 597 Dispatching 598 Memory management 598 WordCounter 599 Iteration 604 Safe Global Initialization 605 Time, Time, Time 606 Dispatch Groups 607 Dispatch Sources 609 Signal sources 611 File read source 612 File write source 613 Timer sources 613 Custom sources 614 Under the Hood 614 Semaphores 614 GCD or NSOperation? 615 For the More Curious: Synchronizing Tasks 616 For the More Curious: The dispatch_debug() Function 616 Exercises 617 Chapter 23聽聽Accessing the Keychain 620 Items and Attribute Lists 621 Searching for Items 623 Reading Data From an Item 625 Editing the Keychain 627 Getting Specific Keychains 628 Keychain Access 628 Making a New Keychain Item 631 Convenience Functions 633 Code Signing 634 Exercises 637 Index 638 A 639 B 640 C 641 D 642 E 644 F 645 G 647 H 648 I 648 J 649 K 649 L 650 M 651 N 653 O 654 P 655 Q 656 R 656 S 657 T 660 U 660 V 660 W 661 X 661 Y 661 Z 661
دانلود کتاب برنامه‌نویسی پیشرفته مک او اس ایکس: راهنمای بزرگ نرد رنچ (راهنماهای بزرگ نرد رنچ)