ptg6843614
A d v a n c e d M a c O S X P r o g r a m m i n g
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
W o r d C o u n t e r . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 7 6
Iteration ............................................................................................................... 581
Safe Global Initialization ........................................................................................ 582
T i m e , T i m e , T i m e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 8 3
Dispatch Groups ................................................................................................... 584
Dispatch Sources ................................................................................................... 586
Signal sources ............................................................................................... 588
File read source ............................................................................................ 589
File write source ........................................................................................... 590
T i m e r s o u r c e s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 9 0
Custom sources ............................................................................................. 591
Under the Hood ............................................................................................ 591
Semaphores .......................................................................................................... 591
GCD or NSOperation? ........................................................................................... 592
F o r t h e M o r e C u r i o u s : S y n c h r o n i z i n g Ta s k s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 9 3
F o r t h e M o r e C u r i o u s : T h e d i s p a t c h _ d e b u g ( ) F u n c t i o n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 9 3
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
K e y c h a i n A c c e s s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 0 5
Making a New Keychain Item ................................................................................. 608
Convenience Functions ........................................................................................... 610