0

在我的 Xamarin.iOS 绑定项目中,我生成了一个名为LSMAUsecase.g.cs. 以下是该课程的内容。

namespace SightCallBinding {
[Protocol (Name = "LSMAUsecase", WrapperType = typeof (LSMAUsecaseWrapper))]
[ProtocolMember (IsRequired = true, IsProperty = true, IsStatic = false, Name = "Name", Selector = "name", PropertyType = typeof (string), GetterSelector = "name", ArgumentSemantic = ArgumentSemantic.None)]
public interface ILSMAUsecase : INativeObject, IDisposable
{
    [Preserve (Conditional = true)]
    string Name {
        [Export ("name")]
        get;
    }   
}

internal sealed class LSMAUsecaseWrapper : BaseWrapper, ILSMAUsecase {
    [Preserve (Conditional = true)]
    public LSMAUsecaseWrapper (IntPtr handle, bool owns)
        : base (handle, owns)
    {
    }

    [BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
    public string Name {
        [Export ("name")]
        get {
            return NSString.FromHandle (global::ApiDefinitions.Messaging.IntPtr_objc_msgSend (this.Handle, Selector.GetHandle ("name")));
        }

    }

}

}

namespace SightCallBinding {
[Protocol()]
[Register("LSMAUsecase", false)]
[Model]


 public unsafe abstract partial class LSMAUsecase : NSObject, ILSMAUsecase {

    [BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
    [EditorBrowsable (EditorBrowsableState.Advanced)]
    [Export ("init")]
    protected LSMAUsecase () : base (NSObjectFlag.Empty)
    {
        IsDirectBinding = false;
        InitializeHandle (global::ApiDefinitions.Messaging.IntPtr_objc_msgSendSuper (this.SuperHandle, global::ObjCRuntime.Selector.GetHandle ("init")), "init");
    }

    [BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
    [EditorBrowsable (EditorBrowsableState.Advanced)]
    protected LSMAUsecase (NSObjectFlag t) : base (t)
    {
        IsDirectBinding = false;
    }

    [BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
    [EditorBrowsable (EditorBrowsableState.Advanced)]
    protected internal LSMAUsecase (IntPtr handle) : base (handle)
    {
        IsDirectBinding = false;
    }

    [BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
    public abstract string Name {
        [Export ("name")]
        get; 
    }

} /* class LSMAUsecase */
}

我想将LSMaUsecase对象传递给方法。但是我不能从中创建任何对象,因为它是一个抽象类。而且我什至无法转换为 LSMAUsecase 类型。它说,无效的演员表。有什么办法可以解决这个我如何传递这种类型的对象。以下是界面中的相关方法。

    [BindingImpl(BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)]
    [Export("sendInvitationForUsecasePhone:toPhone:withReference:andNotify:")]
    [Preserve(Conditional = true)]
    void SendInvitationForUsecasePhone(LSMAUsecase usecase, string phoneNumber, string reference, [BlockProxy(typeof(NIDActionArity2V0))] Action<LSMAPincodeStatus_t, NSString> block);

更新

这是我的扩展课

public class Usecase : LSMAUsecase
{
    public override string Name { get; }
    public Usecase()
        : base()
    {

    }

}

然后我得到了这个异常,因为我没有任何“名称”的值(名称只是获取)。

Foundation.MonoTouchException:抛出 Objective-C 异常。名称:NSInvalidArgumentException 原因:-[LSMAHandler sendInvitationForUsecasePhone:toPhone:withReference:andNotify:]:无法识别的选择器发送到实例 0x282458780

4

0 回答 0