S1r-Lanzelot
S1r-Lanzelot

Reputation: 2266

Base type is missing for @protocol

Short edition:

Does a @protocol with a missing basetype have an inferred basetype of NSObject in Objective-C?


Long edition:

I am binding an Objective C library to C#. One of the protocols in this libraray is missing a base type... Usually I would expect something like this:

@protocol Account <NSObject, NSCopying, NSSecureCoding>

which I define as:

[Protocol, Model]
[BaseType(typeof(NSObject))]
interface Account : INSCopying, INSSecureCoding

But now I am faced with the following:

@protocol Configuring

so it would be defined as:

[Protocol, Model]
interface Configuring

But that doesn't make much sense... As per Microsoft's documentation:

The API definition file consists of a number of interfaces. The interfaces in the API definition will be turned into a class declaration and they must be decorated with the [BaseType] attribute to specify the base class for the class.

So what do I do in this scenario, am I safe to assume the base type of NSObject for this protocol?

Upvotes: 0

Views: 258

Answers (1)

ColeX
ColeX

Reputation: 14475

First, check BaseTypeAttribute.

Every interface (include Protocol) in your definition that has the [BaseType] attribute that declares the base type for the generated object.

Refer to this sample.

Here InfColorPickerControllerDelegate is protocol, we should add [BaseType(typeof(NSObject))] .

Upvotes: 1

Related Questions