Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I believe that you're looking for <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSGetSizeAndAlignment" rel="nofollow"><code>NSGetSizeAndAlignment</code></a>:</p> <blockquote> <p>Obtains the actual size and the aligned size of an encoded type.</p> <pre><code>const char * NSGetSizeAndAlignment ( const char *typePtr, NSUInteger *sizep, NSUInteger *alignp );</code></pre> <p><strong>Discussion</strong><br> Obtains the actual size and the aligned size of the first data type represented by <code>typePtr</code> and returns a pointer to the position of the next data type in <code>typePtr</code>.</p> </blockquote> <p>This is a Foundation function, not part of the base runtime, which is probably why you didn't find it.</p> <p><em><strong>UPDATE:</em></strong> Although you didn't initially mention that you're using Cocotron, it is also available there. You can find it in Cocotron's Foundation, in <a href="http://code.google.com/p/cocotron/source/browse/Foundation/NSObjCRuntime.m" rel="nofollow">NSObjCRuntime.m</a>.</p> <p>Obviously, this is much better than rolling your own, since you can trust it to always correctly handle strings generated by its own runtime in the unlikely event that the encoding characters should change. </p> <p>For some reason, however, it's unable to handle the digit elements of a method signature string (which presumably have something to do with offsets in memory). <a href="https://github.com/mikeash/MABlockClosure/blob/master/MABlockClosure.m" rel="nofollow">This improved version, by Mike Ash</a> will do so:</p> <pre><code>static const char *SizeAndAlignment(const char *str, NSUInteger *sizep, NSUInteger *alignp, int *len) { const char *out = NSGetSizeAndAlignment(str, sizep, alignp); if(len) *len = out - str; while(isdigit(*out)) out++; return out; } </code></pre>
    singulars
    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.
 

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