Re: Category errata in Objective-C
Re: Category errata in Objective-C
- Subject: Re: Category errata in Objective-C
- From: David Hoerl <email@hidden>
- Date: Wed, 03 Apr 2019 15:33:13 -0700
I've had to do some funky things with categories in the past, in at
least one case because some framework had added one but for complex
reasons could not import. So, similar to what Jens said:
The interface description of the category is for the sole purpose of
helping the compiler generate a selector. This has the following
implications:
- you can put the interface description anywhere. You can put it at the
top of one or more using implementation files, as well as the file that
actually has the implementation for the category.
Note: you do NOT need a implementation anywhere. If you ever had a
project that failed to include the category implementation file, you
know it will build and run, then crash when some code tries to use that
category. [Ask me how I know this :-) ]
- suppose you find a category in some framework used by your app, and
want to use it. Or, you may want to know about it so you don't declare a
similar method in your App, then have either the framework or your code
crash because only one of those categories actually is installed.
BIG REQUEST: if you write frameworks or libraries, don't use categories
on anything but your own classes!!! Or, if you must, then namespace them
with some whacky prefix so an app that defines a similar code doesn't
crash! (Ask me how I know this :-) )
_______________________________________________
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