在MacOS 10.9(Mavericks)应用程序中禁用App Nap [英] Disable App Nap in MacOS 10.9 (Mavericks) application

查看:79
本文介绍了在MacOS 10.9(Mavericks)应用程序中禁用App Nap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个接收OSC消息的应用程序.但是,由于10.9的App-Nap技术,应用程序在离开前台后停止对这些消息作出反应. 我想为在10.9上运行的应用程序禁用AppNap,但仍然能够在10.8上运行,因此我尝试了这段代码,但未显示任何效果.

I am writing an application that receives OSC messages. However, due to 10.9's App-Nap-technology the application stops reacting on these messages after leaving foreground. I want to disable AppNap for my application running on 10.9, but still be able to run on 10.8, so I tried this piece of code, but it does not show any effect.

if ([[NSProcessInfo processInfo] respondsToSelector:@selector(beginActivityWithOptions:reason:)]) {
    [[NSProcessInfo processInfo] beginActivityWithOptions:0x00FFFFFF reason:@"receiving OSC messages"];
}

github 上查看完整代码.

if条件似乎按预期工作,并在10.9台计算机上执行.但是,尽管如此,该应用仍被发送到睡眠状态. (活动监视器在我的应用程序中显示"App Nap:Yes").

The if-condition seems to work as expected and is executed on 10.9-machines. But nevertheless the app is sent to sleep. (Activity Monitor shows "App Nap: Yes" for my application).

感谢您的帮助!

推荐答案

活动需要存储在属性中.所以我将其添加到了头文件中:

the activity need to be stored in a property. So I added this in the header-file:

@property (strong) id activity;

然后使用此实现.

if ([[NSProcessInfo processInfo] respondsToSelector:@selector(beginActivityWithOptions:reason:)]) {
    self.activity = [[NSProcessInfo processInfo] beginActivityWithOptions:0x00FFFFFF reason:@"receiving OSC messages"];
}

感谢所有贡献者!

这篇关于在MacOS 10.9(Mavericks)应用程序中禁用App Nap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆