I'm writing a preference pane to control a script I created, and I want to show a sheet on first launch so the user can tell the pane where they installed the script. The sheet appears fine, the problem is that it appears right after you click the button for my pane. This causes System Preferences to Segmentation Fault immediately.
I'm using the command to show the sheet inside awakeFromNib, which may have something to do with it, but I can't get anything inside of mainViewDidLoad to actually execute. Any ideas on what I can do?
Code:
- (void) awakeFromNib
{
NSLog(@"hi");
[sheetController setParentWindow:[NSApp mainWindow]];
BashScript *script = [[BashScript alloc] init];
if (![script loadScriptFromLocation:[self retrieveScriptLocation]])
{
NSLog(@"Error loading script.");
}
else {
[advancedEditor setString:[script getScript]];
}
}
- (NSString*) retrieveScriptLocation
{
NSUserDefaults *preferences = [[NSUserDefaults standardUserDefaults] retain];
NSString *location = [preferences stringForKey:@"scriptLocation"];
if (location != nil)
{
return location;
}
else
{
return [self askForScript];
}
}
- (NSString*) askForScript
{
[sheetController openSheet:nil];
}
EDIT: Here's the stack trace from the crash: http://files.spherecat1.com/prefpanestacktrace.txt