Monday, December 5, 2011

Extending Classes with Categories


Much of the day to day work in object-oriented programming involves using classes that are already written. Sometimes we want our classes to do just a little bit more. That means they need more properties and methods and adding these entities changes the nature of the class. This is called sub-classing and we already covered how to do that.

There are times, however, when we want to extend the abilities of class but we don't want to define a completely new class. You will encounter these situations more and more as you plunge into Objective-C programming. Perhaps more importantly, you will find examples of category use throughout the Mac and iOS programming examples written by Apple and other developers.

So, to extend a class without sub-classing you have the option of using categories. Let's talk about how to do this.

LinkWithin

LinkWithin

Like Us On Facebook and Receive All Updates!

You can also receive Free Email Updates:

Powered By Tutorails