0
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>

int main(int argc, const char * argv[])
{     
@autoreleasepool {

    NSArray* windowList = [[NSArray alloc] init];

    windowList = [NSWindow windowNumbersWithOptions:0];
    NSLog(@"%lu", [windowList count]);
}
return 0;
}

Segfaulting when calling NSWindow windowNumbersWithOptions

4
  • Show the backtrace of the segfault.
    – kperryua
    Jun 21, 2012 at 21:11
  • gist.github.com/2968987
    – Arwald Are
    Jun 21, 2012 at 22:25
  • Crashing down in CG code called by AppKit is almost assuredly a bug. You should file a report with Apple.
    – kperryua
    Jun 25, 2012 at 16:06
  • 1
    You can call this from inside a Cocoa application's delegate method -applicationDidFinishLaunching:, but not in main(). I would guess that the CG calls need a little more setup before you can make this NSWindow call.
    – Jared Kipe
    Jun 27, 2012 at 16:59

1 Answer 1

1

The doc for windowNumbersWithOptions says, for the option value,

If the value 0 is passed instead, then the list returned from the method contains window numbers for visible windows on the active space belonging to the calling application.

Probably your windowList is NULL, because your app didn't create one?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.