I am using NSSavePanel and adding an Accessory View onto it using IKSaveOptions.
Pre-Yosemite it worked great and then Yosemite caused a crash as per: NSSavePanel crashes on Yosemite
I implemented this fix a year ago. Now El Capitan comes along and there is a similar crash but in a different location.
Current Code:
// Let the user choose an output file, then start the process of writing samples
NSSavePanel *savePanel = [NSSavePanel savePanel];
_saveOptions = [[IKSaveOptions alloc] initWithImageProperties: _imageProperties
imageUTType: _imageUTType];
[_saveOptions addSaveOptionsAccessoryViewToSavePanel: savePanel];
NSView * accessoryView = savePanel.accessoryView;
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_8)
{
[accessoryView setTranslatesAutoresizingMaskIntoConstraints:YES];
}
[savePanel setCanSelectHiddenExtension:YES];
[savePanel setNameFieldStringValue:[[_window representedFilename] lastPathComponent]];
[savePanel beginSheetModalForWindow:_window completionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton)
[self savePanelDidEnd:savePanel returnCode:result];
}];
The above code works perfectly on Yosemite however on El Capitan I get an exception thrown when trying to call addSaveOptionsAccessoryViewToSavePanel with Exception:
2015-09-07 09:39:56.224 IKImageViewDemo[1565:108561] An uncaught exception was raised
2015-09-07 09:39:56.224 IKImageViewDemo[1565:108561] Setting autoresizing constraints when autoresizing is off
2015-09-07 09:39:56.231 IKImageViewDemo[1565:108561] (
0 CoreFoundation 0x00007fff974c9a22 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff933b373c objc_exception_throw + 48
2 CoreFoundation 0x00007fff974c97fa +[NSException raise:format:arguments:] + 106
3 Foundation 0x00007fff8c2178ec -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
4 AppKit 0x00007fff964ae2d7 -[NSView(NSConstraintBasedLayout) _setAutoresizingConstraints:] + 143
5 AppKit 0x00007fff9648b5ca -[NSView setTranslatesAutoresizingMaskIntoConstraints:] + 162
6 ImageKit 0x00007fff8aabc6d8 -[IKSaveOptionsHandler setSavePanel:] + 260
7 IKImageViewDemo 0x0000000100002b3c -[Controller saveImage:] + 204
8 libsystem_trace.dylib 0x00007fff9923d082 _os_activity_initiate + 75
9 AppKit 0x00007fff966ac685 -[NSApplication sendAction:to:from:] + 460
So how do I set this up to work on El Capitan now? The fact that I cannot even get to the accessory view as the exception is already thrown is making this very difficult.