Note that there are some explanatory texts on larger screens.

plurals
  1. POMonoTouch conformsToProtocol=False for valid protocols
    text
    copied!<p>I have created <a href="https://github.com/theonlylawislove/MonoTouch.AQGridView/blob/master/MonoTouch.AQGridView/ApiDefinition.cs" rel="nofollow">bindings for AQGridView</a>. The project has a delegate and datasource protocol.</p> <p>The type <code>AQGridView</code> exposes a <code>GridViewDataSource</code> and <code>GridViewDelegate</code> property. When setting either property with a custom class, an error get's throw from the bounded library (not the runtime). There is message is:</p> <blockquote> <p>Argument to -setDataSource must conform to the AQGridViewDataSource protocol</p> </blockquote> <p>This error is thrown manually by calling "conformsToProtocol" within the objective-c library.</p> <pre><code>- (void) setDataSource: (id&lt;AQGridViewDataSource&gt;) obj { if ((obj != nil) &amp;&amp; ([obj conformsToProtocol: @protocol(AQGridViewDataSource)] == NO )) [NSException raise: NSInvalidArgumentException format: @"Argument to -setDataSource must conform to the AQGridViewDataSource protocol"]; _dataSource = obj; _flags.dataSourceGridCellSize = [obj respondsToSelector: @selector(portraitGridCellSizeForGridView:)]; } </code></pre> <p>The delegate has no required methods, so it is easy to "conform", and for the datasource, I have implemented all the required fields. So the question is:</p> <p><strong>Why does <code>conformsToProtocol</code> return NO in iOS when the managed type I send it inherits from the correct type and implements the required methods (if any)?</strong></p> <p>UPDATE</p> <p>I have overrided ConformsToProtocol on our c# type to get the method in the iOS type to pass.</p> <pre><code>public override bool ConformsToProtocol (IntPtr protocol) { return true; } </code></pre> <p>I still don't think I need to do this, but it now works.</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