我正在为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.****
}
谁能帮我?
1条答案
按热度按时间mznpcxlj1#
这是可行的: