I have some code to select the name, without extension, in an NSSavePanel, that I got off of the net a long time ago, and seemed to work fine at the time. I just reused the code and it's now failing. The error is that "[mySavePanel fieldEditor: NO forObject: nil]" is returning nil. If I change "NO" to "YES", it returns a NSText item, but it's not the name editor in the NSSavePanel.
NSSavePanel *mySavePanel = [NSSavePanel savePanel];
[mySavePanel setTitle: @"Restore File"];
[mySavePanel setMessage: @"Select a location and name to restore the file as:"];
[mySavePanel setNameFieldStringValue: currentRecord.originalName];
NSText *editor = [mySavePanel fieldEditor: NO forObject: nil];
if (editor)
{
NSString *nameFieldString = [mySavePanel nameFieldStringValue];
NSString *nameFieldExt = [nameFieldString pathExtension];
if (nameFieldExt != nil)
{
NSInteger newLength = [nameFieldString length] - [nameFieldExt length] - 1;
[editor setSelectedRange: NSMakeRange(0, newLength)];
}
}
A bit stumped here, anyone have an idea why it would return nil?