Prevent NSTimer firing delays in background app

前端 未结 1 977
慢半拍i
慢半拍i 2020-12-11 14:22

I\'m working on a macOS app (let\'s call it the \"display app\") that displays a clock and other data, which is controlled by another app (the \"control app\") on the same m

相关标签:
1条回答
  • 2020-12-11 14:54

    This is App Nap. The display app can do the following to avoid napping:

    id activity = [[NSProcessInfo processInfo] beginActivityWithOptions:NSActivityUserInitiatedAllowingIdleSystemSleep reason:@"whatever"];
    

    When it can allow napping again, you should do:

    [[NSProcessInfo processInfo] endActivity:activity];
    
    0 讨论(0)
提交回复
热议问题