Nathanael Carper Nathanael Carper - 1 month ago 10
Swift Question

Disable App Nap

I really need to disable App Nap in my OS X application in Swift but I've looked all over the web and can't find an answer. Any help would be appreciated.

Answer

Try this:

let myQueue = NSOperationQueue()
let myActivity = NSProcessInfo.processInfo().beginActivityWithOptions(
    NSActivityOptions.UserInitiated,
    reason: "Batch processing files")
myQueue.addOperationWithBlock(
    {
        // Perform batch processing of files here
        NSProcessInfo.processInfo().endActivity(myActivity)
    }
)

Read more about App Nap on Apples reference site here.