迁移到x64 iOS后,Xamarin NetworkReachability SetCallBack方法问题

时间:2014-12-27 17:38:36

标签: ios xamarin.ios xamarin

将我的iOS项目迁移到x64后,我遇到了很多错误,我修复了一切,我无法修复以下内容,我在Xamarin和Apple开发者网站上搜索了很多但没有解决。

Error CS1061: Type `SystemConfiguration.NetworkReachability' does not contain a definition for `SetCallback' and no extension method `SetCallback' of type `SystemConfiguration.NetworkReachability' could be found. Are you missing an assembly reference? (CS1061)

我还导入了以下参考文献:

using System;
using System.Net;
using Foundation;
using UIKit;
using SystemConfiguration;
using CoreFoundation;
using CoreServices;

代码是:

NetworkReachability reachability = new NetworkReachability (new IPAddress (new byte [] {169,254,0,0}));
reachability.SetCallback (OnChange); // <-- seems that this method removed from the class But what I should use instead of it ?

请与我分享您的建议。

1 个答案:

答案 0 :(得分:7)

您需要改为使用reachability.SetNotification()

不再推荐

SetCallback()

[Advice ("Use SetNotification instead")]
public bool SetCallback (NetworkReachability.Notification callback)
{
    return this.SetNotification (callback) == StatusCode.OK;
}