0

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?

S1r-Lanzelot
  • 2,206
  • 3
  • 31
  • 45
  • 1
    Don't confuse class `NSObject` and protocol `NSObject`. `Account ` says `Account` conforms to the `NSObject` protocol. Protocols in Objective-C don't have a base type. – Willeke Mar 29 '18 at 09:26

1 Answers1

1

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))] .

ColeX
  • 14,062
  • 5
  • 43
  • 240