我正在为 Segment/Analytics 开发 iOS 绑定,并在这方面遇到了障碍。
oc 代码我找不到转换为 C# 代码的好主意。
-(SEGReachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref;
当我将代码转换为以下内容时:
[Export("initWithReachabilityRef:")]
unsafe IntPtr Constructor(ref NetworkReachability @ref);
它发生了一个错误:
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.****
}
任何人都可以帮助我吗?