Problem with beginSheetForDirectory


#1

I’m building the program outlined in chapters 17 and 18 on 10.6 with Xcode 3.2.5. There seems to be a problem with this function:

  • (IBAction)showOpenPanel:(id)sender
    {
    NSOpenPanel *panel = [NSOpenPanel openPanel];

    // Run the open panel
    [panel beginSheetForDirectory:nil
    file:@"image.jpg"
    types:[NSImage imageFileTypes]
    modalForWindow:[stretchView window]
    modalDelegate:self
    didEndSelector:
    @selector(openPanelDidEnd:returnCode:contextInfo:)
    contextInfo:NULL];
    }

When I hit file->Open the file selection dialog box comes up but disappears after a second or two. At some point (maybe a second, maybe 30 seconds) the program crashes with:

Program received signal: “EXC_BAD_ACCESS”.
sharedlibrary apply-load-rules all

Is this a problem with the somewhat later version of OSX and/or Xcode? My code is exactly the same as the code in the book.

I have the 4th edition on order, but since it’s based on Lion and the newest Xcode there may be other problems. I’d like a solution that works with what I’m using…

Thanks for your suggestions!