Cocoa 中的 UpdateSystemActivity 等价物是什么?
我正在将 Carbon 应用程序转换为 Cocoa 应用程序,但找不到与 Cocoa 等效的应用程序:
UpdateSystemActivity(UsrActivity);
有 Mac 用户愿意为我指出正确的方向吗?谢谢。
更新:我正在构建 64 位。构建 32 位工作正常,但当我构建 64 位时,我收到 UpdateSystemActivity(和其他)的符号未在此范围内声明的错误。
更新2:我正在导入以下内容:
#import <Cocoa/Cocoa.h>
#import <Carbon/Carbon.h>
#import <OpenGL/CGLMacro.h>
构建 64 位时还需要导入其他内容吗?
UPDATE3:添加#import
没有帮助。我仍然收到编译器错误,告诉我 UpdateSystemActivity 和 UsrActivity 未在此范围内声明。
更新4:好的,在 OSServices/Power.h 上找不到文件。我正在针对 10.5 SDK 进行构建,快速搜索显示:
$ pwd
/Developer/SDKs
$ find . -name Power.h
./MacOSX10.3.9.sdk/Developer/Headers/CFMCarbon/OSServices/Power.h
./MacOSX10.3.9.sdk/Developer/Headers/CFMCarbon/Power.h
./MacOSX10.3.9.sdk/Developer/Headers/FlatCarbon/Power.h
./MacOSX10.3.9.sdk/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/Headers/Power.h
./MacOSX10.4u.sdk/Developer/Headers/CFMCarbon/OSServices/Power.h
./MacOSX10.4u.sdk/Developer/Headers/CFMCarbon/Power.h
./MacOSX10.4u.sdk/Developer/Headers/FlatCarbon/Power.h
./MacOSX10.4u.sdk/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/Headers/Power.h
./MacOSX10.5.sdk/Developer/Headers/FlatCarbon/Power.h
./MacOSX10.5.sdk/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/Headers/Power.h
但我得到:
Mac.mm:6:29: error: OSServices/Power.h: No such file or directory
Mac.mm:6:29: error: OSServices/Power.h: No such file or directory
I'm converting a Carbon app to a Cocoa app and I can't find the Cocoa equivalent for:
UpdateSystemActivity(UsrActivity);
Any Mac people out there care to point me in the right direction? Thanks.
UPDATE: I'm building 64bit. Building 32bit works fine, but I get symbol not declared in this scope errors for UpdateSystemActivity (and others) when I build for 64bit.
UPDATE2: I'm importing the following:
#import <Cocoa/Cocoa.h>
#import <Carbon/Carbon.h>
#import <OpenGL/CGLMacro.h>
Is there some other thing I need to import when building 64bit?
UPDATE3: Adding #import <CoreServices/CoreServices.h>
did not help. I still get compiler errors telling me UpdateSystemActivity and UsrActivity was not declared in this scope.
UPDATE4: Okay, file not found on OSServices/Power.h. I'm building against the 10.5 SDK and a quick search shows:
$ pwd
/Developer/SDKs
$ find . -name Power.h
./MacOSX10.3.9.sdk/Developer/Headers/CFMCarbon/OSServices/Power.h
./MacOSX10.3.9.sdk/Developer/Headers/CFMCarbon/Power.h
./MacOSX10.3.9.sdk/Developer/Headers/FlatCarbon/Power.h
./MacOSX10.3.9.sdk/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/Headers/Power.h
./MacOSX10.4u.sdk/Developer/Headers/CFMCarbon/OSServices/Power.h
./MacOSX10.4u.sdk/Developer/Headers/CFMCarbon/Power.h
./MacOSX10.4u.sdk/Developer/Headers/FlatCarbon/Power.h
./MacOSX10.4u.sdk/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/Headers/Power.h
./MacOSX10.5.sdk/Developer/Headers/FlatCarbon/Power.h
./MacOSX10.5.sdk/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/Headers/Power.h
Yet I get:
Mac.mm:6:29: error: OSServices/Power.h: No such file or directory
Mac.mm:6:29: error: OSServices/Power.h: No such file or directory
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 OS X 10.6 及更高版本中,IOKit 可用于禁用睡眠。当您想要禁用睡眠时创建 IOPMAssertion 并在想要再次允许睡眠时销毁它。
更多信息:https://developer.apple.com/library/mac/ qa/qa1340/_index.html
In OS X 10.6 and later IOKit can be used to disable sleep. Create an IOPMAssertion when you want to disable sleep and destroy it when you want to allow sleep again.
More information: https://developer.apple.com/library/mac/qa/qa1340/_index.html
这里的问题似乎是 OSServices.h 中的行,如果定义了 __LP64__ ,则排除 Power.h。在 10.5 上构建 64 位时,UpdateSystemActivity 确实是未定义的。
好消息是该符号确实存在于 CoreServices.framework 中。有两种方法可以访问它。
我手头没有 SnowLeopard 的副本,但接下来要做的就是检查它是否已修复。如果不是,请提交 RADAR,因为这显然是 SDK 错误。
The issue here appears to be the line in OSServices.h that excludes Power.h if __LP64__ is defined. When building 64 bit on 10.5 UpdateSystemActivity is indeed undefined.
The good news is that the symbol does actually exist in CoreServices.framework. There are two ways to get access to it.
I don't have a copy of SnowLeopard handy, but the next thing to do would be to check if it's fixed there. If it isn't, file a RADAR as this is clearly an SDK bug.
您应该仍然能够从 Cocoa 应用程序中调用
UpdateSystemActivity
——它尚未被标记为已弃用。API 的文档指定导入 CoreServices/CoreServices.h 来获取 API,但是通过标头(特别是在 OSServices/OSServices.h 中)搜索显示该文件在 64 位环境中被省略。尽管如此,
Power.h
的某些部分(其中定义了UpdateSystemActivity
)对于 64 位是关闭的,而UpdateSystemActivity
不是其中之一。鉴于此,请尝试直接
#import
并查看是否有效。 (您必须在项目中包含 CoreServices 框架才能找到标头。)You should still be able to call
UpdateSystemActivity
from within your Cocoa app -- it has not been marked deprecated.The documentation for the API specifies importing
CoreServices/CoreServices.h
to get the API -- however hunting through the headers (notably inOSServices/OSServices.h
) shows that the file is omitted in a 64bit environment. Nevertheless, there are sections ofPower.h
(whereUpdateSystemActivity
is defined) that are turned off for 64bits, andUpdateSystemActivity
is not one of them.In light of that, try to
#import <OSServices/Power.h>
directly and see if that works. (You'll have to include the CoreServices framework in your project for the header to be found as well.)