> On Mar 29, 2019, at 2:51 PM, Alex Zavatone <z...@mac.com> wrote:
> 
> Also, I seem to remember the esteemed Jens stating that as soon as a category 
> class is in your project, it applies to all objects instantiated from the 
> base class and we only had to do an import if we wanted to use the category 
> methods in the debugger.  Please correct me if I am wrong here.

No, you have to #import the header if you want to use the category methods in a 
source file.

At _compile_ time, when you call one of those methods the compiler needs to 
have seen a prior declaration of that method or it'll flag an error. Thus, you 
need to have #included the header file declaring the category. (The compiler 
_could_ go ahead and decide you know what's right, and just compile a call to 
that method anyway; back in the old days it used to, but that turned out to 
lead to lots of stupid runtime crashes caused by mistyped method names.)

At _runtime_, the category patches the class implementation when your app 
starts, so its methods are available everywhere.

—Jens
_______________________________________________

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