Re: Category errata in Objective-C
Re: Category errata in Objective-C
- Subject: Re: Category errata in Objective-C
- From: Cody Garvin <email@hidden>
- Date: Fri, 29 Mar 2019 18:32:07 -0700
Just for clarification, an empty name in the parens is referred to as an
extension and not a nameless category. An extension has extra abilities such as
adding properties. Just being explicit for those that may not know.
Please excuse mobile typos
> On Mar 29, 2019, at 5:55 PM, Jens Alfke <email@hidden> wrote:
>
>
>
>> On Mar 29, 2019, at 2:51 PM, Alex Zavatone <email@hidden> 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 (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
_______________________________________________
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