title: Getting argument type in a method
body: <p>I am trying to subclass a certain class and override some of its private methods. This is dangerous, could fail, could not pass Apple's review (In the AppStore), could have terrible effects, etc, but this is just for experimental/educational purposes :)</p>
  
  <p>For example let's say I want to know the type of first argument of the instance method <code>keyboardInput:shouldInsertText:isMarkedText:</code> of <code>UITextView</code> :</p>
  
  <pre><code>SEL selector = @selector(keyboardInput:shouldInsertText:isMarkedText:);
  Class class = [UITextView class];
  Method method = class_getInstanceMethod(class, selector);
  char *arg = method_copyArgumentType(method, 0);
  printf("_%s_\n", arg);
  free(arg);
  </code></pre>
  
  <p>However In the console I only get <code>_@_</code> . 
  I think <code>@</code> means <em>object</em> but an object of what class? (I thought I would get the name of the class of the argument) Is it possible to get the class of that parameter using other <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html" rel="nofollow">objective-c runtime functions</a> or any other mean?</p>
  
  <p>PS: In the example I used a class of Cocoa touch but I could have tried exactly the same with a class of Cocoa. So this should not be specific to iOS.</p>
  
  <p>SOLVED:</p>
  
  <p>I have tried in the simulator what Dave suggested, it worked!</p>
  
  <p><code>(gdb) info all-registers</code> gave me a long list of values,... </p>
  
  <pre><code>((gdb) po *(id*)($ebp + 8)
  &lt;MyTextView: 0x5911270; baseClass = UITextView; frame = (80 70; 240 323); text = 'Lorem ipsum dolor sit er ...'; clipsToBounds = YES; autoresize = RM+BM; layer = &lt;CALayer: 0x5c0c7d0&gt;; contentOffset: {0, 0}&gt;
  
  (gdb) p *(SEL*)($ebp + 12)
  $5 = (SEL) 0xbd19
  
  (gdb) po *(id*)($ebp + 16)
  &lt;UIWebDocumentView: 0xa02f000; frame = (0 0; 240 457); text = 'Lorem ipsum dolor sit er ...'; opaque = NO; userInteractionEnabled = NO; layer = &lt;UIWebLayer: 0x5c35070&gt;&gt;
  
  (gdb) po *(id*)($ebp + 20)
  t
  
  (gdb) p *(id*)($ebp + 24)
  $6 = (id) 0x0
  </code></pre>
  
  <p>Which makes sense since the key I pressed was a single "t" so it was not marked text ("0x0") so I is OK to think that the first argument should be of type <code>UIWebDocumentView</code>.</p>
  
  <p>Just one little thing (irrelevant in this case), how could I get the method name from a SEL in gbd? for example <code>$5</code> ?</p>