Reputation: 619
I managed to bind successfully a native iOS library but when I run I have one problem with conformsToProtocol validation failing when trying to validate a protocol implementation in one class looked up by NSClassFromString.
obj-C Code:
Class cl = NSClassFromString("MyProtocolClass");
if (cl == Nil) {
// Can't instantiate class
result = NO;
} else {
// Check class is compatible with the protocol
if (![cl conformsToProtocol:@protocol(MyProtocol)]) { <------ FAILS HERE
//class does not implement MyProtocol
result = NO;
}
}
Protocol Code:
@protocol MyProtocol <NSObject>
@optional
- (void)method1;
@end
My Binding code:
[Model, BaseType(typeof(NSObject))]
public partial interface MyProtocol
{
[Export("method1")]
void Method1();
}
My class:
[Adopts("MyProtocol")]
[Register ("MyProtocolClass")]
public class MyProtocolClass : MyProtocol
{
}
I think that NSClassFromString is not taking in consideration the protocols that I implement in C#.
Any Ideas how to make this work?
Thanks
Upvotes: 0
Views: 172
Reputation: 19345
Xamarin.iOS does currently not support exporting protocols defined in C# to Objective-C.
It's on the roadmap for a future version, but exactly when hasn't been determined yet.
Upvotes: 2