How do I disable app nap in Swift? Im new to programming and I am building a timer(just for practice), and I am afraid app nap will break my timer.
See Question&Answers more detail:osHow do I disable app nap in Swift? Im new to programming and I am building a timer(just for practice), and I am afraid app nap will break my timer.
See Question&Answers more detail:osI found that this solution works in Swift as well.
Create a class or global variable
var activity: NSObjectProtocol?
And assign it after which App Nap will be disabled
activity = NSProcessInfo().beginActivityWithOptions(NSActivityOptions.UserInitiated, reason: "Good Reason")