Difference between subclass and category? Which place used effectively in both items?And difference between category and protocol? Need real time example.
Thanks
Difference between subclass and category? Which place used effectively in both items?And difference between category and protocol? Need real time example.
Thanks
Really short explanation. I can point you in a direction at least.
Subclass Inherit functions of a class. You want to have the same behaviour as the class you just subclassed but with some of your own custom functionality.
Category Add extra functionality to a class that fits your needs. In other words you could add a method to a class (NSString for example) that lets you count the characters. This can later be called on your NSString class.
Protocol You can delegate tasks to another class that has set itself as a delegate. You can force classes to implement certain methods.