IBOutlets always nil in NSSavePanel Accessory view

I am using XCode 11.2. I created an NSViewContoller with a loaded nib file and added the view to NSSavePanel. The view displays and the NSTextfields in the view are there but they never connect to the view controller. Tried all sorts of things to force connection but nothing happens. I have used accessory views many times before with NSOpenPanel with no issue, but this is really got me stumped. Is this a bug in XCode 11.2 with Catalina?


My code looks something like this:


MyViewController *mvc=[[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];

NSView *av=[mvc view];


NSSavePanel *panel=[NSSavePanel savePanel];

[panel setAllowedFileTypes:[NSArray arrayWithObjects:@"tif", nil]];

[panel setExtensionHidden:NO];

[panel setMessage:@"Save the original file."];

[panel setAccessoryView:av];

if([panel runModal]==NSModalResponseOK){

NSString *someText=[mvc textView]; // this is always nil

...

....

The view controller has the textView connected using IB - it all looks ok but the textView is always nil at runtime. The method [mvc textView] returns a string from the NSTextView. When I look at it in the debugger the NSTextView is nil - that is, it never gets connected. How do I force it to?

Did you retry rebuilding the connections in IB for the textView ?


    MyViewController *mvc=[[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
    NSView *av=[mvc view];

    NSSavePanel *panel=[NSSavePanel savePanel];
    [panel setAllowedFileTypes:[NSArray arrayWithObjects:@"tif", nil]];
    [panel setExtensionHidden:NO];
    [panel setMessage:@"Save the original file."];
    [panel setAccessoryView:av];
    if([panel runModal]==NSModalResponseOK){
        NSString *someText=[mvc textView]; // this is always nil


Could you also test moving line 10, to see what you get:


    MyViewController *mvc=[[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
    NSView *av=[mvc view];

    NSSavePanel *panel=[NSSavePanel savePanel];
    [panel setAllowedFileTypes:[NSArray arrayWithObjects:@"tif", nil]];
    [panel setExtensionHidden:NO];
    [panel setMessage:@"Save the original file."];
    [panel setAccessoryView:av];
    NSString *someTex2t=[mvc textView]; // is it nil here ?

    if([panel runModal]==NSModalResponseOK){
        NSString *someText=[mvc textView]; // this is always nil

Tried all you said - and yes, accessing the textView id is always nil. It's even nil in my vciew controller and it's nil if I try to "set needs display:YES" on it. Tried exiting xcode and restarting, tried cleaning and rebuilding the project but the textviews never get connected. Eventually gave up and did something else. Is this a bug with Catalina? Found multiple problems with Catalina already.

Could you show how you declared textView (IBOutlet). Try giving it a different name as myTextView, just to check.

IBOutlets always nil in NSSavePanel Accessory view
 
 
Q