NSOperation and NSOperationQueue, Threading in a simple way
Anyone who has worked with threading know about all the problems that can arise and how difficult it can be to debug. When a program an iPhone application in Objective C will often be used for easy threading to avoid the GUI locks up when performing various tasks. This is where it's nice to know that there are two objects called NSOperation and NSOperationQueue.
To learn how these two works is incredibly simple. One might look at the code in one instance at Apple TopSongs or read the class documentation NSOperation . Personally, I like to read the documentation to try out for yourself, as this provides a better understanding of how classes work.
A small example
User NSInvocationOperation here which is a sub class of NSOperation
@interface OperationViewController : UITableViewController { NSOperationQueue *operationQueue; NSInvocationOperation *operation; } @property (nonatomic, retain) NSOperationQueue *operationQueue; @property (nonatomic, retain) NSInvocationOperation *operation; #import "OperationViewController.h" @implementation OperationViewController @synthesize operationQueue; @synthesize operation; - (void)viewDidLoad { [super viewDidLoad]; self.title = @"Operation"; [operationQueue setMaxConcurrentOperationCount:1]; operationQueue = [[NSOperationQueue alloc] init]; } If you now wish to run an operation in the background you need only add a NSInvocationOperation in NSOperationQueue
operation = [[[NSInvocationOperation alloc] initWithTarget:self selector:@selector(runInBackground) object:nil] autorelease]; [self.operationQueue addOperation:operation]; 



