Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The Obj-C runtime has changed in Objective-C 2, the code you quoted uses the older one. </p> <p>(Well, on 32 bit apps, it's more correct to say there're two interfaces to the same runtime, depending on how you compile your binary; both work in the end. But it's easier to think that things changed in Objective-C 2. And you should use the newer APIs because it's easier to use, and it works both in 32 bit and 64 bit.)</p> <p>New references are <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Introduction/Introduction.html" rel="noreferrer">the Guide</a> and <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html" rel="noreferrer">the Reference</a>. The basic change is that the internal <code>struct</code> is no longer public, is opaque. So you can't access its member directly. Instead, you need to use an API.</p> <p>Typically things are easier in the new runtime. To replace an <code>IMP</code>, one just uses </p> <pre><code>IMP class_replaceMethod(Class cls, SEL name, IMP imp, const char *types); </code></pre> <p>To get the type encoding, use </p> <pre><code>const char * method_getTypeEncoding(Method method); </code></pre> <p>against the original method you're replacing. In practice, that would be </p> <pre><code>method_getTypeEncoding(class_getInstanceMethod([SomeClass class], @selector(someSelector:you:want:to:replace:))); </code></pre> <p>To learn more about the runtime, I heartily recommend the wonderful series of blog posts <a href="http://www.mikeash.com/pyblog/" rel="noreferrer">Friday Q&amp;A</a> by Mike Ash.</p> <p>Have fun and good luck!</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