zoukankan      html  css  js  c++  java
  • [翻译] PBJNetworkObserver 网络监控

    PBJNetworkObserver 网络监控

    https://github.com/piemonte/PBJNetworkObserver

    Introduction

    'PBJNetworkObserver' is an iOS component for detecting changes in network reachability state as well as connection type. For example, it can determine when an IP is being routed through a Wireless Wide Area Network (WWAN) interface such as 3G or LTE.

    'PBJNetworkObserver'是一个iOS组件,用来监测网络状态的改变或者网络连接类型的改变.例如,他可以检测一个IP地址能否通过无线网络连接到广域网.

    Mobile devices are frequently moving through connectivity challenged environments made up of various network interfaces. This component enables apps to easily monitor these network changes and allow opportunities to refresh, cache, or even provide user interface feedback when they occur.

    移动设备会经常的变更连接网络的方式,这个组件能帮助app快速的监测网络的改变,给你机会来刷新,缓存或者是给用户提示信息告知发生了什么.

    Some common uses include auto-refresh, logic that can be triggered for a view if the device upgrades from an EDGE network to a WiFi access point allowing more or higher quality data to be quickly loaded.

    一些常见的用处有自动刷新,还有一些实现逻辑如监测到了用户从EDGE网络变更为WiFi后允许大容量的数据快速加载.

    Observers are notified when a network is no longer reachable, the network becomes reachable, and when the network interface type changes.

    这些情况下会通知观察者:网络连接不上了,网络刚刚能连接上,网络连接的类型改变了.

    If you have questions, github issues is a great means to start a discussion, this allows others to benefit and chime in on the project too.

    如果你有什么疑问,这个 github issues 地方可以很便利的讨论问题,让别人看到问题后也能改进这个项目.

    Usage

    #import "PBJNetworkObserver.h"
    
    @interface MyClass () <PBJNetworkObserverProtocol>
    
    // add observer on init or viewDidAppear
        [[PBJNetworkObserver sharedNetworkObserver] addNetworkReachableObserver:self];
    
    // remove observer on dealloc or on viewDidDisappear
        [[PBJNetworkObserver sharedNetworkObserver] removeNetworkReachableObserver:self];
    
    - (void)networkObserverReachabilityDidChange:(PBJNetworkObserver *)networkObserver
    {
        // network status changed, these properties can also be queried at any time
        BOOL isNetworkReachable = [networkObserver isNetworkReachable];
        BOOL isCellularConnection = [networkObserver isCellularConnection];
        NSLog(@"network status changed reachable (%d),  cellular (%d)", isNetworkReachable, isCellularConnection);
    }
    
    
  • 相关阅读:
    Eclipse无法正常启动,弹出对话框内容为 A Java Runtime...
    redis入门常用的命令操作(总结 一)
    初级工程师的面试
    公司金融学理论--MM理论
    以太坊开发环境搭建
    如何以树形结构显示文件目录结构
    Neural Network Basics
    大前端公共知识梳理
    出SS表
    iOS weak关键字
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/3685493.html
Copyright © 2011-2022 走看看