> On 9 Mar 2015, at 8:58 pm, Dragan Milić <mi...@mac.com> wrote:
> 
> Sure, no problem. Since it’s a bit long, I attached it as a separate ObjC 
> source file. A few notes:
> 
> * It’s rather old code (not made by me) that I haven’t looked into for years 
> until this problem appeared.
> * I rearranged it a bit for easier reading, so there may be some 
> copy/paste/typo errors, but you should get the overall idea what it does.
> * All drawing related code is contained within unique methods, no overriding.
> * I was “lying”, there is a small NSButton category (defined within the same 
> file), but it just checks if a button is of a checkbox type.
> 
> Thanks for looking into this, as I really hit a dead end with it.
> 


In Xcode, add OBJC_PRINT_REPLACED_METHODS (value: YES) to your scheme's 
environment variables. Then all of the methods replaced by categories are 
logged when your app launches. While the list can be long and might take some 
time to go through, it will show you if any of your category methods are 
replacing anything - it's a much more reliable way to check than doing a class 
dump.

If you're not using those category methods, remove them. Most of them seem to 
be convenience methods that are possible "nice to haves" rather than vital to 
use NSView. Some appear to me to wholly misunderstand how a view stack 
(involving semi-transparancy for example) is actually drawn. Others are things 
that could be useful in particular circumstances but you probably wouldn't want 
to apply to every view your app ever instantiates including framework ones. For 
those custom views of yours that use these things, relocate that code to the 
custom view. It may mean a small duplication of code across a few different 
views, but it will be a lot safer than swapping out NSView wholesale. NSView 
just may be Cocoa's single most complicated class (any other contenders?). As a 
result, you probably can't foresee all possible effects of adding a category on 
it.

--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

Reply via email to