> On Apr 25, 2017, at 9:51 AM, Dave <d...@looktowindward.com> wrote: > > Mac Project. > > Hi All, > > I’m using performSelector: withObject: afterDelay: in order to postpone > further processing until after the current method/run loop as expired, this > puts the request at the End of the Queue, my question is, is there anyway of > putting it at the head of the Queue so it gets processing before other > requests? > > All the Best > Dave
Consider using NSOperationQueue (OperationQueue if you’re using Swift) instead of performSelector:withObject:afterDelay:, and have a look at the queuePriority property on Operation/NSOperation. The following code: > import Foundation > > let op1 = BlockOperation { > print("op1") > } > > let op2 = BlockOperation { > print("op2") > } > > let quitOp = BlockOperation { > exit(0) > } > > quitOp.addDependency(op1) > quitOp.addDependency(op2) > > op1.queuePriority = .veryLow > op2.queuePriority = .veryHigh > > OperationQueue.main.addOperations([op1, op2, quitOp], waitUntilFinished: > false) > > RunLoop.main.run() outputs: > op2 > op1 This shouldn’t be taken as a guarantee, but it does make it more likely that your operation will be executed before others. Charles _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com