Search code examples
multithreadingnsoperation

Run NSOperation on Main Thread


I built a NSOperation to run on a background thread, but I have since optimized the operation such that I might be better suited running it in the main thread. Is there a way to direct my NSOperation to run on the main thread instead of a background thread so that I can test things out without significant refactoring?


Solution

  • You can do this in the NSOperationQueue by using mainQueue

    http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOperationQueue_class/Reference/Reference.html