• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSDrawer not always sending -drawerDidOpen: to delegate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDrawer not always sending -drawerDidOpen: to delegate


  • Subject: NSDrawer not always sending -drawerDidOpen: to delegate
  • From: Jerry Krinock <email@hidden>
  • Date: Sat, 16 Feb 2013 17:31:10 -0800

In an app running in Mac OS X 10.8, I have set a drawer's delegate to be its window controller, in the window controller's -awakeFromNib…

- (void)awakeFromNib {
    …
    [drawer setDelegate:self] ;
    …
}

About a week or so, I find the drawer behaving as though -drawerDidOpen: was not being received by the window controller.  This happened today.  I placed a breakpoint at the entry to -drawerDidOpen:, opened and closed the drawer several times, and got no breaks.  So I sent some messages via lldb to get the address of the drawer…

(lldb) po [[NSApp delegate] inspectorController]
(id) $0 = 0x0000000108213bc0 <InspectorController: 0x108213bc0>
(lldb) po [$0 window]
(id) $1 = 0x0000000108186bc0 <NSPanel: 0x108186bc0>
(lldb) po [$1 drawers]
(id) $2 = 0x0000000100d3c4b0 <__NSArrayI 0x100d3c4b0>(
<NSDrawer: 0x10829e840>,
<NSDrawer: 0x108254e30>
)
…
<Sent more messages to drawer's content to see which of the two is the misbehaving one.  It was the second one.>
…
(lldb) po [0x108254e30 delegate]
(id) $4 = 0x0000000108213bc0 <InspectorController: 0x108213bc0>

Looks OK.  So I then set the delegate to nil, and then re-set it back to the window controller…

(lldb) expr (void)[0x108254e30 setDelegate:nil]
<no result>
(lldb) po [0x108254e30 delegate]
(id) $8 = 0x0000000000000000 <nil>
(lldb) expr (void)[0x108254e30 setDelegate:$4]
<no result>
(lldb) po [0x108254e30 delegate]
(id) $9 = 0x0000000108213bc0 <InspectorController: 0x108213bc0>

and, voila, upon opening the drawer, my breakpoint in -drawerDidOpen: broke, and the drawer started behaving as expected.

My conclusion is that there is an intermittent bug in Mac OS X, that sometimes -[NSDrawer setDelegate:] doesn't flip all of its switches.  I've now tried to work around this by resending -setDelegate: to the drawer like this

    [drawer setDelegate:self] ;
    [drawer performSelector:@selector(setDelegate:)
                 withObject:self
                 afterDelay:3.0] ;

The delay of 3 seconds I pulled out of the air.  I have no idea what I'm doing and cannot test since the problem is not reproducible.

(My app delegate retains the window controller, so this does not crash if user closes the window within 3 seconds after opening it.)

Has anyone else ever seen such misbehavior by NSDrawer?  Are there any other possible explanations?

Thanks,

Jerry Krinock



_______________________________________________

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


  • Follow-Ups:
    • Re: NSDrawer not always sending -drawerDidOpen: to delegate
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Multiple methods named...
  • Next by Date: Re: NSDrawer not always sending -drawerDidOpen: to delegate
  • Previous by thread: Re: Multiple methods named...
  • Next by thread: Re: NSDrawer not always sending -drawerDidOpen: to delegate
  • Index(es):
    • Date
    • Thread