I'm new to cocoa programming but I picked up a project and keep running into an error. The error is :
"Implicit declaration of function '_CGSDefaultConnection' is invalid in C99"
I google'd it but couldn't find a definite answer as to what was wrong. But from what I can tell, the line cid = (CGSConnectionID)_CGSDefaultConnection();
is not being defined in the correct way.
The full code is below:
#define kIconLevel -2147483628
+ (NSArray*)allIconRects
{
NSMutableArray *rects = [NSMutableArray array];
int results[1000];
int count = -1;
CGSConnectionID cid;
cid = (CGSConnectionID)_CGSDefaultConnection();
CGSGetWindowList( cid, 0, 1000, results, &count );
int i = 0;
for (i = 0; i < count; i++) {
CGWindowLevel level;
CGSGetWindowLevel( cid, results[i], &level );
if (level == kIconLevel) {
NSRect bounds;
CGSGetWindowBounds(cid, results[i], (CGRect*) &bounds);
[rects addObject:[NSValue valueWithRect:bounds]];
}
}
return rects;
}
Any help will be greatly appreciated :)