Graham, You said, "you close the sheet itself by sending -endSheet to the SHEET, not its parent”. Correct me if I am wrong, but I think you send endSheet: to the parent window, with the sheet window to be dismissed a parameter. Same for the deprecated NSApp method of the same name.
The doc says: - endSheet: Ends a document-modal session and dismisses the specified sheet. Declaration OBJECTIVE-C - (void)endSheet:(NSWindow *)sheetWindow Parameters sheetWindow The window object that represents the sheet to be dismissed. Best, Michael > > Message: 1 > Date: Wed, 25 Nov 2015 09:54:03 +1100 > From: Graham Cox <graham....@bigpond.com> > To: Jerry Krinock <je...@ieee.org> > Cc: Cocoa Developers <cocoa-dev@lists.apple.com> > Subject: Re: -[NSWindow parentWindow] for sheet never works? > Message-ID: <8bd39b37-6915-4a2f-a356-c05f37459...@bigpond.com> > Content-Type: text/plain; charset=utf-8 > > >> On 25 Nov 2015, at 3:47 AM, Jerry Krinock <je...@ieee.org> wrote: >> >> ’m updating an old project which used the -[NSApp beginSheet:::::] methods >> to use -[NSWindow beginSheet:completionHandler:]. In so doing, I now need >> the parent window in my action methods, so I can send the -[NSWindow >> endSheet::] message which runs the completion handler. In many cases, the >> sheet is handy but the parent window is not. No problem, I thought, just >> use send -[NSWindow parentWindow] to the sheet. >> >> Unfortunately this always returns nil, unless I set is using -[NSWindow >> setParentWindow:] beforehand, which the documentation and common sense says >> is unnecessary. >> >> Is the non-functioning of -[NSWindow parentWindow] a known bug, or am I >> doing something wrong? > > > Hi Jerry, > > You don’t send the parent window endSheet to run the completion handler - you > close the sheet itself by sending -endSheet to the SHEET, not its parent. If > you need to communicate something back to the parent window or code that ran > the sheet, just do it directly from the completion handler. As a block, it > can capture variables from its initiating scope. It’s all far easier than the > old approach. > > —Graham > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com