Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="https://github.com/jspahrsummers/libextobjc">extObjC has the NEATEST stuff</a> you can do with Protocols / Categories... first off is <code>@concreteprotocol</code>...</p> <ul> <li>Defines a "concrete protocol," which can provide default implementations of methods within protocol. </li> <li>An <code>@protocol</code> block should exist in a header file, and a corresponding <code>@concreteprotocol</code> block in an implementation file.</li> <li>Any object that declares itself to conform to this protocol will receive its method implementations, but only if no method by the same name already exists.</li> </ul> <p><kbd>MyProtocol.h</kbd></p> <pre><code>@protocol MyProtocol @required - (void)someRequiredMethod; @optional - (void)someOptionalMethod; @concrete - (BOOL)isConcrete; </code></pre> <p><kbd>MyProtocol.m</kbd></p> <pre><code> @concreteprotocol(MyProtocol) - (BOOL)isConcrete { return YES; } ... </code></pre> <p>so declaring an object <code>MyDumbObject : NSObject &lt;MyProtocol&gt;</code> will automatically return <code>YES</code> to <code>isConcrete</code>.</p> <p>Also, they have <code>pcategoryinterface(PROTOCOL,CATEGORY)</code> which "defines the interface for a category named CATEGORY on a protocol PROTOCOL". Protocol categories contain methods that are automatically applied to any class that declares itself to conform to PROTOCOL." There is an accompanying macro you also have to use in your implementation file. See the docs.</p> <p>Last, but NOT least / not <em>directly</em> related to <code>@protocols</code> is <code>synthesizeAssociation(CLASS, PROPERTY)</code>, which "synthesizes a property for a class using associated objects. This is primarily useful for adding properties to a class within a category. PROPERTY must have been declared with <code>@property</code> in the interface of the specified class (or a category upon it), and must be of object type."</p> <p><strong>So many</strong> of the tools in this library open (way-up) the things you can do with ObjC... from multiple inheritance... to well, your imagination is the limit.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload