Disable App Nap

2019-08-13 08:42发布

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.

1条回答
Anthone
2楼-- · 2019-08-13 09:06

Try this:

let myQueue = OperationQueue()
    let myActivity = ProcessInfo.processInfo.beginActivity(
        options: ProcessInfo.ActivityOptions.userInitiated,
        reason: "Batch processing files")
    myQueue.addOperation(
        {
            // Perform batch processing of files here
            ProcessInfo.processInfo.endActivity(myActivity)
        }
    )

Read more about App Nap on Apples reference site here.

查看更多
登录 后发表回答