Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: [paper] Full Trait Support for Objective-C (or almost)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [paper] Full Trait Support for Objective-C (or almost)



On 28.07.2011, at 00:24, Ondřej Čada wrote:
>> You could probably use a trampoline in combination with a category on
>> NSObject to achieve cleaner syntax, e.g.:
>> [[self runtimeSuper] foo];
>
> I believe it would be solveable; nevertheless, myself, I am yet to see a reasonable code which does [super something] in a trait code. So, in my implementation, I simply documented super as invalid with "undefined results" :)

 Practical examples:

1) a GUI editor. You want to subclass each UI element (pushbutton, text field, slider etc.) with the same code to handle clicks in "editing" mode differently than in "run" mode. You want to override -drawRect: to draw the selection highlight and resize handles, and you want to override the view's resetCursorRects to change the cursor to an arrow/resize handles instead of whatever the view would set. To get the view to draw under the highlight, you actually need to call through to super first.

2) Adding forwarding of unused key presses to NSTableView and NSOutlineView. You really just want to override a few NSTableView methods, but since you can't make NSOutlineView retroactively subclass from your class, you need to duplicate the code. In those cases you also need to call super.

Both of these uses could be cleanly solved by using traits. Or am I misunderstanding where you're thinking calls to super are uncommon?

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >[paper] Full Trait Support for Objective-C (or almost) (From: Lars Sonchocky-Helldorf <email@hidden>)
 >Re: [paper] Full Trait Support for Objective-C (or almost) (From: Ondřej Čada <email@hidden>)
 >Re: [paper] Full Trait Support for Objective-C (or almost) (From: Hamish Allan <email@hidden>)
 >Re: [paper] Full Trait Support for Objective-C (or almost) (From: Ondřej Čada <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.