Binding ObjC constructor with IntPtr

ADR_vtgADR_vtg Member ✭✭

I Have some problems binding following Objective-C class:

@interface MyObject : NSObject 
    - (instancetype _Nonnull)initWithDataObject:(MyDataObject* _Nonnull)data;

// some more methods
@end

I like to bind the constructor with:

[BaseType(typeof(NSObject))]
[DisableDefaultCtor]
interface MyObject
{
        [Export("initWithDataObject:")]
        IntPtr Constructor(IntPtr dataObj);

}

But i get following compile error:

error CS0111: Type 'MyObject' already defines a member called '.ctor' with the same parameter types

Without binding the constructor, the binding compiles and runs but MyObject gets created with an IntPtr handle from the MyDataObject.
Is it not possible to create a binding for this constructor or am i missing something?

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    Did you have created another method called Constructor()?

  • ADR_vtgADR_vtg Member ✭✭

    No, I have no other method called Constructor().

  • ADR_vtgADR_vtg Member ✭✭

    Had some time to further investigate my problem. The binding works correctly, but only if i use it in the iOS forms project.

    If i use the binding in my iOS library MyObject gets created with the IntPtr handle from MyDataObject. Perhaps there is problem with my project setup.

Sign In or Register to comment.