tingtingan
tingtingan

Reputation: 11

xamarin.ios binding Segment-Analytics errors

I am working on the iOSbinding for Segment/Analytics and meeting a block on this.

The oc code I cannot find a good idea to convert to C# code.

-(SEGReachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;

when i converted code to below:

        [Export("initWithReachabilityRef:")]
        unsafe IntPtr Constructor(ref NetworkReachability @ref);

it happened a error:

Error CS0311: The type SystemConfiguration.NetworkReachability' cannot be used as type parameterT' in the generic type or method ObjCRuntime.Runtime.GetNSObject<T>(System.IntPtr)'. There is no implicit reference conversion fromSystemConfiguration.NetworkReachability' to `Foundation.NSObject' (CS0311) (Anayltics.IOS)

    [Export ("initWithReachabilityRef:")]
    [CompilerGenerated]
    public SEGReachability (ref SCNetworkReachabilityRef @ref)
        : base (NSObjectFlag.Empty)
    {
        IntPtr @refValue = IntPtr.Zero;

        IsDirectBinding = GetType ().Assembly == global::ApiDefinition.Messaging.this_assembly;
        if (IsDirectBinding) {
            InitializeHandle (global::ApiDefinition.Messaging.IntPtr_objc_msgSend_ref_IntPtr (this.Handle, Selector.GetHandle ("initWithReachabilityRef:"), ref refValue), "initWithReachabilityRef:");
        } else {
            InitializeHandle (global::ApiDefinition.Messaging.IntPtr_objc_msgSendSuper_ref_IntPtr (this.SuperHandle, Selector.GetHandle ("initWithReachabilityRef:"), ref refValue), "initWithReachabilityRef:");
        }

        @ref = @refValue != IntPtr.Zero ? Runtime.GetNSObject<Anayltics.SCNetworkReachabilityRef> (@refValue) : null; //**--**error happened in this line.****
    }

Any one can help me?

Upvotes: 1

Views: 68

Answers (1)

Masuk Pavel
Masuk Pavel

Reputation: 23

This works:

using SystemConfiguration;

unsafe IntPtr Constructor (ref SystemConfiguration.NetworkReachability reachability);

Upvotes: 0

Related Questions