-6

Difference between subclass and category? Which place used effectively in both items?And difference between category and protocol? Need real time example.

Thanks

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
  • check this out http://stackoverflow.com/questions/360992/protocol-versus-category – Ayrad Aug 26 '14 at 09:40
  • You need to read a Objective-C for beginners book. It will tell you everything under the chapter called "Categories". – Fogmeister Aug 26 '14 at 09:41
  • 2
    @KrishJacky help yourself first. When you get stuck then come back here and ask a question that isn't answered in every single objective-c book and tutorial website. – Fogmeister Aug 26 '14 at 09:42
  • Sorry for this question. – KrishJacky Sep 04 '14 at 12:47
  • 1
    This is the third time this question has been changed to a completely NEW question. Please, post a NEW question and don't change your old question every time. – Mikael Jun 16 '15 at 07:09

1 Answers1

0

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.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Mikael
  • 3,572
  • 1
  • 30
  • 43