Disable app sleep in Swift
2 answers
I found this solution works in Swift as well.
Create a class or global variable
var activity: NSObjectProtocol?
And assign it, after which the Nap app will be disabled
activity = NSProcessInfo().beginActivityWithOptions(NSActivityOptions.UserInitiated, reason: "Good Reason")
+6
source to share