Advanced Mac OS X Programming
xiii
Bitmap ........................................................................................................ 543
BitmapView ................................................................................................. 544
CalcOperation ............................................................................................... 546
MandelOpperAppDelegate .............................................................................. 549
NSBlockOperation ......................................................................................... 551
Complex-Lifetime Operations .................................................................................. 553
KVO properties ............................................................................................. 554
ImageSnarfer ........................................................................................................ 555
ImageCanvas ................................................................................................ 556
SnarfOperation .............................................................................................. 558
NSURLConnection delegate methods ................................................................ 561
ImageSnarferAppDelegate ............................................................................... 562
Mop-up ....................................................................................................... 565
Exercises ............................................................................................................. 566
22. Grand Central Dispatch ............................................................................................. 569
GCD Terminology ................................................................................................. 571
Queues ................................................................................................................ 571
Object-Oriented Design .......................................................................................... 573
Dispatch API ....................................................................................................... 574
Queues ........................................................................................................ 574
Dispatching .................................................................................................. 575
Memory management ..................................................................................... 575
WordCounter ........................................................................................................ 576
Iteration ............................................................................................................... 581
Safe Global Initialization ........................................................................................ 582
Time, Time, Time ................................................................................................. 583
Dispatch Groups ................................................................................................... 584
Dispatch Sources ................................................................................................... 586
Signal sources ............................................................................................... 588
File read source ............................................................................................ 589
File write source ........................................................................................... 590
Timer sources ............................................................................................... 590
Custom sources ............................................................................................. 591
Under the Hood ............................................................................................ 591
Semaphores .......................................................................................................... 591
GCD or NSOperation? ........................................................................................... 592
For the More Curious: Synchronizing Tasks ............................................................... 593
For the More Curious: The dispatch_debug() Function ................................................. 593
Exercises ............................................................................................................. 594
23. Accessing the Keychain ............................................................................................ 597
Items and Attribute Lists ........................................................................................ 598
Searching for Items ............................................................................................... 600
Reading Data From an Item .................................................................................... 602
Editing the Keychain ............................................................................................. 604
Getting Specific Keychains ..................................................................................... 605
Keychain Access ................................................................................................... 605
Making a New Keychain Item ................................................................................. 608
Convenience Functions ........................................................................................... 610