receptionist pattern question: NSOperationQueue vs. GCD
receptionist pattern question: NSOperationQueue vs. GCD
- Subject: receptionist pattern question: NSOperationQueue vs. GCD
- From: Matt Neuburg <email@hidden>
- Date: Wed, 15 Feb 2012 11:19:49 -0800
In Apple's delightful documentation of Chris Kane's Receptionist pattern (which I think of as a trampoline), the key method looks like this:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context {
[queue addOperationWithBlock:^{
task(keyPath, object, change);
}];
}
https://developer.apple.com/library/mac/#documentation/General/Conceptual/CocoaEncyclopedia/ReceptionistPattern/ReceptionistPattern.html
Typically, "queue" is [NSOperationQueue mainQueue], our goal being to get ourselves back on the main thread in response to receiving a KVO notification that might have been sent on a background thread.
My question is simply this: in a world that has GCD, is there any reason why we wouldn't have "queue" be a GCD dispatch queue (probably the main queue) and call dispatch_asynch? Putting it even more generally (and this is probably my *real* question), is there any reason why I'd ever use NSOperationQueue's addOperationWithBlock given the existence of GCD?
Thx for your thoughts - m.
--
matt neuburg, phd = email@hidden, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Programming iOS 5! http://shop.oreilly.com/product/0636920023562.do
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden