3 Replies
      Latest reply on Nov 24, 2019 12:35 AM by Claude31
      tjd Level 1 Level 1 (0 points)

        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?

        • Re: IBOutlets always nil in NSSavePanel Accessory view
          Claude31 Level 8 Level 8 (8,355 points)

          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