From the documentation in NSArray :
NSArray is a "free bridge" with its partner Core Foundation, CFArray Handbook. This means that a Core Foundation type is an interchangeable function or method call with a bridge Foundation object that transfers one type to another. Therefore, in the API where you see the NSArray * parameter, you can pass in CFArrayRef and in the API where you see the CFArrayRef parameter, you can pass an instance of NSArray. This arrangement also applies to your specific NSArray subclasses.
So the problem should be calling two methods. Again, from the documentation, CGWindowListCopyWindowInfo has a return value:
An array of CFDictionaryRef types, each of which contains information about one of the windows of the current user session. If there is no window matching the specified criteria, the function returns an empty array. If you call this function from outside the GUI session or when the window server is not running, this function returns NULL.
and CGWindowListCreate has a return value:
An array of CGWindowID values โโcorresponding to the desired windows. If there are no windows matching the desired criteria, the function returns an empty array. If you call this function from outside the GUI Security Session or when the window server is not running, this function returns NULL.
When you call NSLog(@"%@",array); , a description message is sent to each object in the array. Floats, BOOLs, and ints do not respond to this message. For example, you will receive an error message
NSLog(@"Printing 2: %@",2);
but the error will disappear if you use the int call:
NSLog(@"Printing 2: %d",2);
In your case, CGWindowListCreate returns an array of CGWindowID values, and these are 32-bit unsigned integers. Therefore, they will not respond to %@ , but will respond to %u . Therefore, the fix is โโto print the array manually using %u .