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 protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]