Reputation: 40329
I'm new to objective-c and need to extend a standard class of a framework with an instance variable plus accessors. I heard that this is done with a so called "category", which sounds pretty confusing to me. How does this basically work?
Upvotes: 5
Views: 2983
Reputation: 9982
A category adds methods to the table of methods inside a class. It's very handy for adding application specific methods to existing framework classes.
If you need to add instance variables to a class, a category won't do the job -- categories only add methods, not data. To add instance variables, you must subclass.
Upvotes: 11
Reputation: 67829
A category of a class adds methods to that class. It cannot add instance variables.
If you need to add instance variables you may want to subclass instead.
Upvotes: 7