Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Objective-C Runtime Reference</strong></p> <p>It's easy to forget that the syntactic sugar of Objective-C is converted to normal C function calls that are the Object-C Runtime. It's likely that you will never need to actually delve into and use anything in the runtime. That is why I would consider this a 'hidden feature'.</p> <p>Let me give a way one might use the runtime system.</p> <p>Let's say that someone is designing an external framework API that will be used by third parties. And that someone designs a class in the framework that abstractly represents a packet of data, we'll call it <code>MLAbstractDataPacket</code>. Now it's up to the application who is linking in the framework to subclass <code>MLAbstractDataPacket</code> and define the subclass data packets. Every subclass must override the method <code>+(BOOL)isMyKindOfDataPacket:(NSData *)data</code>.</p> <p>With that information in mind...</p> <p>It would be nice if <code>MLAbstractDataPacket</code> provided a convenience method that returned the correct initialized class for a packet of data that comes in the form <code>+(id)initWithDataPacket:(NSData *)data</code>.</p> <p>There's only one problem here. The superclass doesn't know about any of its subclasses. So here you could use the runtime method <code>objc_getClassList()</code> along with <code>objc_getSuperclass()</code> to find the classes that are subclasses of MLAbstractDataPacket. Once you have a list of subclasses you can then try <code>+isMyKindOfDataPacket:</code> on each until one is found or not found.</p> <p>The reference information about this can be found at <a href="http://developer.apple.com/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html" rel="nofollow noreferrer">http://developer.apple.com/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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