【问题标题】:Why reachability of IP address never gets called back?为什么IP地址的可达性永远不会被回调?
【发布时间】:2013-06-14 02:24:37
【问题描述】:

我已经为此苦苦挣扎了两天。 https://stackoverflow.com/questions/17077345/reachability-of-ip-address


我终于找到了解决办法,所以如果有人遇到同样的问题,请看下面的答案。

【问题讨论】:

    标签: ios ip automatic-ref-counting ip-address reachability


    【解决方案1】:

    经过几天的研究,我找到了解决方案。 瓶颈是即使在“侦听”模式下也调用当前可达性状态,当使用 IP 地址初始化时(如下面的一个 sn-p,没有其余应用程序上下文)。

    if (isAddressReachability)
    {
        dispatch_async(dispatch_queue_create("com.eppz.reachability.workaround", NULL), ^
        {
            SCNetworkReachabilityFlags flags;
            if (SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags))
            {
                //'Manual' invocation of callback functionality.
                dispatch_async(dispatch_get_main_queue(), ^ //Dispatch delegate callback on the main thread.
                {
                    [self parseFlags:flags];
                    [self.delegate reachabilityChanged:self];
                });
            }
        });
    }
    

    详情请见:http://eppz.eu/blog/reachability-with-ip-address-doesnt-work/

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-12
    • 1970-01-01
    • 2013-07-22
    • 2018-11-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多