#import typedef uint64_t CGSSpace; typedef uint64_t CGSManagedDisplay; typedef int CGSConnection; typedef enum _CGSSpaceSelector { kCGSSpaceCurrent = 5, kCGSSpaceOther = 6, kCGSSpaceAll = 7 } CGSSpaceSelector; extern CGSManagedDisplay kCGSPackagesMainDisplayIdentifier; extern CFArrayRef CGSCopySpaces(const CGSConnection cid, CGSSpaceSelector type); extern void CGSManagedDisplaySetCurrentSpace(const CGSConnection cid, CGSManagedDisplay display, CGSSpace space, CGSSpace space2); extern int CGSManagedDisplayGetCurrentSpace(const CGSConnection cid, CGSManagedDisplay display); extern void CGSShowSpaces(const CGSConnection cid, CFArrayRef spaces); extern void CGSHideSpaces(const CGSConnection cid, CFArrayRef spaces); extern CGSConnection _CGSDefaultConnection(void); extern id CGSWillSwitchSpaces(const CGSConnection cid, CFArrayRef spaces); int main(int argc, char *argv[]) { @autoreleasepool { NSLog(@"Current space: %d", CGSManagedDisplayGetCurrentSpace(_CGSDefaultConnection(), kCGSPackagesMainDisplayIdentifier)); NSArray *spaces = @[ ]; id result = CGSWillSwitchSpaces(_CGSDefaultConnection(), (__bridge CFArrayRef)spaces); NSLog(@"Will change spaces result: %@", result); CGSManagedDisplaySetCurrentSpace(_CGSDefaultConnection(), kCGSPackagesMainDisplayIdentifier, 3, 3); spaces = @[ @1, @3 ]; CGSShowSpaces(_CGSDefaultConnection(), (__bridge CFArrayRef)spaces); spaces = @[ @1 ]; CGSHideSpaces(_CGSDefaultConnection(), (__bridge CFArrayRef)spaces); NSLog(@"Current space: %d", CGSManagedDisplayGetCurrentSpace(_CGSDefaultConnection(), kCGSPackagesMainDisplayIdentifier)); } }