• 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
Re: firstResponder KVO snow leopard crash; bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: firstResponder KVO snow leopard crash; bug?


  • Subject: Re: firstResponder KVO snow leopard crash; bug?
  • From: Corbin Dunn <email@hidden>
  • Date: Thu, 19 Nov 2009 10:41:33 -0800

On Nov 18, 2009, at 5:06 PM, Sean McBride wrote:

> On 11/18/09 9:00 AM, Corbin Dunn said:
>
>> Oh -- another thing. Does your subclass of NSCollectionView override:
>>
>> (void)viewWillMoveToWindow:(NSWindow *)window {
>>
>> but not call super? If not... call super! Your classes should always
>> call super if it is defined in a superclass, unless you have a good
>> reason to hide the super's behavior.
>
> Corbin,
>
> This comment caught by eye.  As a general principle, I certainly agree
> with your comment.
>
> But I never call super when I override those methods, and I guess I
> should be doing so.  Does NSView's implementation do something or only
> NSCollectionView?

Only NSCollectionView. But, that is a good question; how would one know they should call super? In general, I think people should *always* call super, unless they have some specific reason not to. Assuming that super may or may not do anything is simply an implementation detail -- in the future we may add code that does something.

Maybe for this case we should add the declaration to NSCollectionView and state that it overrides the method to do more work. The .NET framework tends to do this to let people know when that happens, and it might be nice for AppKit to do it too.

>
> The docs often comment about calling super.  In NSView's case, they do
> for beginDocument, beginPageInRect:atPlacement:, drawRect:, endDocument,
> viewWillStartLiveResize, etc. but they don't for the
> viewWillMoveToWindow:.  I guess I'm so used to seeing a comment, that if
> I don't see one, I don't call super.  At least one Apple example also doesn't:
> <http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/
> EventOverview/MouseTrackingEvents/MouseTrackingEvents.html>
>
> Should one call super for all the viewWill/Did methods?

My opinion is yes. Please log a documentation bug asking to be clarified (you can copy my email into it).

corbin


_______________________________________________

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

References: 
 >firstResponder KVO snow leopard crash; bug? (From: Aaron Clarke <email@hidden>)
 >Re: firstResponder KVO snow leopard crash; bug? (From: Corbin Dunn <email@hidden>)
 >Re: firstResponder KVO snow leopard crash; bug? (From: "Sean McBride" <email@hidden>)

  • Prev by Date: Re: setToolTip: not working
  • Next by Date: Re: Help with Background Tasks
  • Previous by thread: Re: firstResponder KVO snow leopard crash; bug?
  • Next by thread: Re: firstResponder KVO snow leopard crash; bug?
  • Index(es):
    • Date
    • Thread