how to declare IntPtr in iOS Binding project on Xamarin

26 Views Asked by At

I'm trying to connect iOS Framework to Xamarin. (I've never experienced Xamarin.) so I did succeed to bind iOS Framework.

also I declare the protocol DownloadDelegate

when I bind my framework, DownloadDelegate is inherited iNativeObject by Xamarin.

and I made the class BookDownloadHelper : DownloadDelegate { } It requires to declare Handle public IntPtr Handle => IntPtr.zero

when I call download() on Xamarin, Xamarin app crash due to Handle

 public class SampleBridgeiOS 
 {
    private BookDownloadHelper helper = new BookDownloadHelper();
    public void closeBook()
    {
        Console.WriteLine("close book");
    }

    public void donwload(String pk)
    {

        var info = new DownloadBookInfo();

        info.Author = "test";
        info.Title = "test";

        ViewerBookManager.DownloadBook(info, this.helper); // ViewerBookManaer is the class of iOS framework
    }
}

BookDownloadHelper

public class BookDownloadHelper : IBookDownloadDelegate
{

    public IntPtr Handle => IntPtr.Zero;
}   

DownloadBook function

public static void DownloadBook (DownloadBookInfo info, IBookDownloadDelegate @delegate)
{
    IntPtr nonNullHandle = NativeObjectExtensions.GetNonNullHandle   ((INativeObject)(object)info, "info");
    IntPtr nonNullHandle2 = NativeObjectExtensions.GetNonNullHandle ((INativeObject)@delegate, "delegate");
    Messaging.void_objc_msgSend_IntPtr_IntPtr (class_ptr, Selector.GetHandle ("downloadBook:delegate:"), nonNullHandle, nonNullHandle2);
}

I don't know how to declare Handle. please help me...

0

There are 0 best solutions below