iphone - Categories vs Informal Protocols -


I think I understand the difference between the (formal) protocol and the categories. Now, if I have found this right, then there should be informal protocol categories (usually defined on NSOBIES) which are used for some purposes (as opposed to the formal protocol, to give only a part of the method listed in it). is done. I need to make sure about it: can someone confirm that an informal protocol is just a category (or interpretation of difference)? An extension category for class functionality - This is the implementation of some methods:

  @ Interface NSObject (MyCategory) - (zero) doSomething; @end ... @ Implementation NSObject (MyCategory) - (zero) doSomething {// do something ...} @end  

Formal protocol is completely different if you have any If you are familiar with other object-oriented languages, then it's like the interface (Java, C ++, C # etc).
The protocol can be linked to the implementation of any class like this:

  @protocol MyProtocolrereired - (zero) doSomething; @optional - (zero) doSomethingOptional; @ And ... @interface myclass: NSobigant & lt; MyProtocol & gt; {} @end ... @EmploymentMyClass- (zero) doSomething {// do something ...} @end  

According to the document, the informal protocols are categories of the NSObject class ( I have never used this approach):

  @interface NSOBX (MyInformalProtocol) - (empty) doSomething; @end ... @ Implementation NSObject (MyInformalProtocol) - (zero) doSomething {// do something ...} @end  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -