How to perform delayed calls using NSOperationQueue?
How to perform delayed calls using NSOperationQueue?
- Subject: How to perform delayed calls using NSOperationQueue?
- From: Jens Alfke <email@hidden>
- Date: Mon, 21 Jul 2014 17:42:01 -0700
I’m starting to port a pretty complex source base from using NSURLConnection to using NSURLSession. (Primarily because this is the only way to get around the only-four-sockets-per-host limitation.) I thought it was going to be straightforward, until I saw that NSURLSession only supports scheduling delegate calls on an NSOperationQueue, not an NSRunLoop. So that means I now also have to convert a number of runloop dependencies in the same code, which I don’t understand how to do.
Case in point: I have a couple of things that require the use of delayed performs to schedule timing. What’s the equivalent of -performSelector:withObject:afterDelay: (or of NSTimer) for code that’s running under the control of an NSOperationQueue? I know this call won’t work on a queue (because the thread it’s on probably won’t have a runloop), but I’ve looked at the API docs and headers and don’t see anything comparable. Dispatch queues have dispatch_after, and I’d much rather use GCD than NSOperationQueue anyway*, but NSURLSession is forcing my hand.
—Jens
* (I know there’s now an underlyingQueue property on NSOperationQueue, but that’s only in iOS 8 and I can’t rely on that yet.)
_______________________________________________
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