August 2011
Intermediate to advanced
552 pages
23h 48m
English
You can use multiple threads in a Cocoa program. As usual, Cocoa brings a nice set of clean APIs that provide the threading features. All of the caveats above regarding race conditions and performance apply when using Cocoa, as well as some additional gotchas.
NSThread is the class that abstracts threads. To create a new thread, use the class method
+ (void)detachNewThreadSelector: (SEL) aSelector toTarget: (id) aTarget withObject: (id) anArgument;
aSelector is a selector that describes a method aTarget can receive. aSelector's signature is
- (void) aSelector: (id) anArgument;anArgument is what gets passed to this method. This call works just like pthread_create() in that the thread starts executing with the first ...
Read now
Unlock full access