Using NSSavePanel causes "running implicitly" runtime warning

I've recently noticed that use of NSSavePanel in our macOS application causes one or more warnings to the console, like this:

WARNING: <NSSavePanel: 0x171a466d0> found it necessary to prepare implicitly; please prepare panels using NSSavePanel rather than NSApplication or NSWindow.

WARNING: <NSSavePanel: 0x171a466d0> found it necessary to start implicitly; please start panels using NSSavePanel rather than NSApplication or NSWindow.

WARNING: <NSSavePanel: 0x171a466d0> running implicitly; please run panels using NSSavePanel rather than NSApplication.

We are running the save panel modally, as supported by NSSavePanel.h:

Code Block
NSSavePanel * panel = [NSSavePanel savePanel];
[panel setTitle:@"Record Movie"];
...
NSModalResponse rtn = [panel runModal];


In other code, we use RunModalSheetForDialog() which gives a similar warning:

<NSSavePanel: 0x7f9c70224810> running implicitly; please run panels using NSSavePanel rather than NSApplication.

Why these warnings, and what can I do about it?

Why these warnings?

Apple is trying to move developers off of old APIs.

what can I do about it?

Use a modern API. Look in the documentation for runModel. Are there any new methods listed near it that use completion handlers?
I have the exact same question! I've tried both in Objective-C and Swift (XCode 11.6, macOS SDK 10.15)

Apple is trying to move developers off of old APIs.

Old API? Documentation for NSSavePanel:runModal doesn't warn about undesirable use or possible future depreciation. And neither the warnings. So using it seems legitimate.

Use a modern API. Look in the documentation for runModel. Are there any new methods listed near it that use completion handlers?

I've tried beginWithCompletionHandler, and it does work without warning. But it is not modal, so main application window still accessible, which is not wanted.

I've tried beginSheetModalForWindow:completionHandler, but i can't get it to work.

In my MainViewController.m file, in an IBAction for a button:

Code Block
NSSavePanel *savePanel = [NSSavePanel savePanel];
[savePanel beginSheetModalForWindow:[self.view window] completionHandler:^(NSModalResponse result){
if (result == NSModalResponseOK) { ... }
...
}];

But i've got this first:

Code Block
[General] -[NSNib _initWithNibNamed:bundle:options:] could not load the nibName: MainViewController in bundle (null).
[General] (
0 CoreFoundation 0x00007fff31307b57 __exceptionPreprocess + 250
1 libobjc.A.dylib 0x00007fff6a14e5bf objc_exception_throw + 48
2 CoreFoundation 0x00007fff313079b5 +[NSException raise:format:] + 189
3 AppKit 0x00007fff2e55f18d -[NSNib _initWithNibNamed:bundle:options:] + 607
4 AppKit 0x00007fff2e55eee7 -[NSViewController _nibWithName:bundle:] + 174
5 AppKit 0x00007fff2e55eaf1 -[NSViewController loadView] + 134
6 AppKit 0x00007fff2e55e90b -[NSViewController _loadViewIfRequired] + 72
7 AppKit 0x00007fff2e55e888 -[NSViewController view] + 23
8 TestSavePanel01 0x0000000100001c89 -[MainViewController ButtonPressed:] + 425
(...)

I've made some research and found some informations, so for View Controller object, inside the Attribute inspector, i've added my XIB name inside "Nib name" (MainMenu). but then i get:

Code Block
[Nib Loading] Failed to connect (delegate) outlet from (MainViewController) to (AppDelegate): missing setter or instance variable
[General] -[MainViewController loadView] loaded the "MainMenu" nib but no view was set.
[General] (
0 CoreFoundation 0x00007fff31307b57 __exceptionPreprocess + 250
1 libobjc.A.dylib 0x00007fff6a14e5bf objc_exception_throw + 48
2 CoreFoundation 0x00007fff313079b5 +[NSException raise:format:] + 189
3 AppKit 0x00007fff2e55ed4f -[NSViewController loadView] + 740
4 AppKit 0x00007fff2e55e90b -[NSViewController _loadViewIfRequired] + 72
5 AppKit 0x00007fff2e55e888 -[NSViewController view] + 23
6 TestSavePanel01 0x0000000100001c89 -[MainViewController ButtonPressed:] + 425
(...)

I've not been able to get any further.

So some more precise explanations, suggestions and maybe even a code sample would be very welcome!

I'm a complete newbie in macOS development, and Apple really doesn't help a lot, providing a documentation that looks like much like a catalog or dictionnary than a real documentation with code examples, like ones can find in other environment/langages.

Thanks in advance.
Using NSSavePanel causes "running implicitly" runtime warning
 
 
Q