Re: Modal Window Failure on 10.10.2
Re: Modal Window Failure on 10.10.2
- Subject: Re: Modal Window Failure on 10.10.2
- From: Ken Thomases <email@hidden>
- Date: Sun, 08 Feb 2015 19:30:15 -0600
On Feb 8, 2015, at 5:44 PM, Charles Jenkins <email@hidden> wrote:
> I updated my OS yesterday, and now my modal window doesn’t work (which probably means I’m doing it wrong and just got lucky before).
>
> I created the window by asking XCode to create a subclass of NSWindowController and making sure the “also create xib” checkbox was checked. Then I designed the UI, outlets and actions, and wrote the short bit of code that’s supposed to call up the window in my document controller.
>
> The window’s name is OpenXmlExportSettings, and the code that displays it looks like this:
>
> if ( self.openXmlExportSettings == nil ) {
> self.openXmlExportSettings = [[OpenXmlExportSettings alloc] init];
> }
Here you use the -init method to initialize the object. Does your class override that method? Does something call -initWithWindowNibName: to pass in the name of your NIB?
> OpenXmlExportSettings* settings = self.openXmlExportSettings;
>
> NSInteger result = [NSApp runModalForWindow:settings.window];
Have you tried logging the value of settings.window before this line?
> I haven’t made any changes to this since last week when it worked, but like I said, that doesn’t mean I’m sure this was good code to begin with.
>
> Now when runModalForWindow: is called, I get this crash before the window ever appears:
>
> 2015-02-08 16:24:04.155 MyApp[2989:720882] *** Assertion failure in -[NSApplication _commonBeginModalSessionForWindow:relativeToWindow:modalDelegate:didEndSelector:contextInfo:], /SourceCache/AppKit/AppKit-1344.72/AppKit.subproj/NSApplication.m:4048
> 2015-02-08 16:24:04.159 MyApp[2989:720882] An uncaught exception was raised
> 2015-02-08 16:24:04.159 MyApp[2989:720882] Modal session requires modal window
> I’m focusing on that line which says “Modal session requires modal window.” Could that mean there’s an incorect setting I don’t know about in the NIB file? Or do I have to do something to tell the window controller to wake up the window before using it?
I suspect that you're passing nil as the argument to -runModalForWindow:. That could be because the window controller hasn't been given the name of a NIB to load or it could be because the "window" outlet is not connected. (That outlet is connected by default in the NIB created by Xcode following the steps you described, but you may have accidentally disconnected it.)
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden