我想在我的应用中获取当前工作区。我找到了一种从Using third-party libraries for App Engine Standard docs实现目标的方法:
-(int)spaceNumber
{
CFArrayRef windowsInSpace = CGWindowListCopyWindowInfo(kCGWindowListOptionAll | kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
for (NSMutableDictionary *thisWindow in (NSArray *)windowsInSpace) {
if ([thisWindow objectForKey:(id)kCGWindowWorkspace]){
return [[thisWindow objectForKey:(id)kCGWindowWorkspace] intValue];
}
}
return -1;
}
但是现在(我的情况下是macOS 10.13.3)valexa's answer不再存在了。那么有没有其他方法可以实现我的目标呢?
提前致谢!