Forum Xamarin.iOS

(Binding) Interface of [Protocol] does not inherit from NSObject

I was binding a library when I came across an error that IMyProtocol was not found. I researched, asked this question and found the solution, I needed to add

interface IMyProtocol { }

So I did, but now I am running into compiler errors that say IMyProtocol does not inherit from NSObject.

How can I solve this?

The binding code in specific is this:

IPTPusherChannelAuthorizationDelegate ChannelAuthorizationDelegate { get; set; }

// @property (nonatomic, weak) id<PTPusherChannelAuthorizationDelegate> channelAuthorizationDelegate;
[NullAllowed, Export("channelAuthorizationDelegate", ArgumentSemantic.Weak)]
NSObject WeakChannelAuthorizationDelegate { get; set; }

The generated code is this:

public IPTPusherChannelAuthorizationDelegate ChannelAuthorizationDelegate {
    get {
        return WeakChannelAuthorizationDelegate as IPTPusherChannelAuthorizationDelegate;
    set {
        WeakChannelAuthorizationDelegate = value;

And here in the setter I receive the compiler error

PusheriOS/PTPusher.g.cs(40,40): Error CS0266: Cannot implicitly convert type Pusher.iOS.IPTPusherChannelAuthorizationDelegate to Foundation.NSObject. An explicit conversion exists (are you missing a cast?) (CS0266) (Pusher)

How can I solve this?


  • tuyenvtuyenv VNUniversity ✭✭✭

    Have you managed to get it done?

  • AdanAdan USUniversity

    [BaseType(typeof(NSObject)), Model]
    interface WeakChannelAuthorizationDelegate

Sign In or Register to comment.