EXC_BAD_ACCESS when calling NSOpenPanel
EXC_BAD_ACCESS when calling NSOpenPanel
- Subject: EXC_BAD_ACCESS when calling NSOpenPanel
- From: Darren Wheatley <email@hidden>
- Date: Tue, 24 Nov 2009 00:51:54 +0000
Hi,
I have the following code as the action from a button click:
- (IBAction)chooseFile:(id)sender;
{
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
[openPanel setCanChooseDirectories:NO];
[openPanel setCanCreateDirectories:NO];
[openPanel beginSheetForDirectory:nil
file:nil
types:[NSArray arrayWithObject:@"txt"]
modalForWindow:window
modalDelegate:self
didEndSelector:@selector(fileOpenDidEnd:returnCode:context:)
contextInfo:nil];
}
- (void)fileOpenDidEnd:(NSOpenPanel*)openPanel
returnCode:(NSInteger)code
context:(void*)context
{
if (code == NSCancelButton) return;
[self setFilePath:[openPanel filename]];
[filePathField setStringValue:[openPanel filename]];
}
On my 10.6.2 iMac running XCode 3.2.1 it builds and runs fine. On my
MacBook Pro with exactly the same OS version (10.6.2) and XCode version
I get a crash - EXC_BAD_ACCESS when I run it.
The file open dialog pops up for a second but then disappears before I
can click on anything.
The fileOpenDidEnd method does not get called.
Any idea why identical code built with the same version of XCode running
on the same version of Snow Leopard works on one machine and crashes on
another? Both are clean builds of Snow Leopard rather than upgrades.
Regards
Darren.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden