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?
+4
A:
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.
mouviciel
2009-05-14 09:03:59
+2
A:
You may wish to refer to Apple's documentation on this, found here. Also, searching Google for "Objective-C categories" provides a number of quality examples.
Brad Larson
2009-05-14 17:56:36
+1
A:
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.
Don McCaughey
2009-05-14 18:15:25