Reputation: 2002
I must have misunderstood Categories
I made a category on a class to extend it with some methods, and make some methods abstract following the OOP guidelines. But I thought that only when I #import
and use the category will those methods in the category be called. Instead I find when I #import
and use the base class, that this class will automatically call that method but in the Category on the class, not itself.
What I wanted was if the user tried to use this method in the class without a category a exception would get trowed. And this way I could make different categories on the same class with slightly different internal behavior.
Am I just misunderstanding Categories ?
Upvotes: 0
Views: 136
Reputation: 162712
Categories add methods to a class without condition or other means of picking and choosing.
Once the methods are added to the class, there is no removal short of mucking with the runtime directly.
Subclasses inherit the additional methods.
It doesn't matter if you #import
the method declarations or not.
If you want different versions of a class, declare different subclasses.
Upvotes: 1