zoukankan      html  css  js  c++  java
  • [翻译] FBNetworkReachability

    FBNetworkReachability

    You can use FBNetworkReachabilty class to get network reachability on iOS device.

    你可以用FBNetworkReachabilty来获悉网络链接是否可用。

    Usage

    (1) Getting connection mode 下获取到网络状态值

    FBNetworkReachabilityConnectionMode mode =
        [FBNetworkReachability sharedInstance].connectionMode;
    switch (mode) {
        case FBNetworkReachableNon:
        break;
    
        case FBNetworkReachableWiFi:
        break;
    
        case FBNetworkReachableWWAN:
        break;
    }
    

    You can get the connection mode from 'connectionMode' property. 你也可以从connectionMode属性值中获取到网络状态

    (3) Checking reachability 检测网络是否可以连上

    if ([FBNetworkReachability sharedInstance].reachable) {
        :
    }
    

    You can get the rechability flag. 你可以获取到网络状态

    (4) Using notification 使用通知

    FBNetworkReachability posts FBNetworkReachabilityDidChangeNotification when the network reachability changs. To use the notification you can write the event driven code.

    [[NSNotificationCenter defaultCenter]
        addObserver:self
           selector:@selector(didChangeNetworkReachability:)
               name:FBNetworkReachabilityDidChangeNotification
             object:nil];
    [[FBNetworkReachability sharedInstance] startNotifier];
    
    - (void)didChangeNetworkReachability:(NSNotification*)notification
    {
        FBNetworkReachabiity* network = [notification object];
            :
    }
    

    Features

    • FBNetworkReachabiity does not work in background. FBNetworkReachabiity不能在后台运行
    • FBNetworkReachabiity posts the newest network rechability change. FBNetworkReachabiity会发送最新的网络修改的状态
    • The instances has same URL points to same instance internally. 
    • Thread-safe 线程安全
    • Requirements: SystemConfiguration.framework 需要使用SystemConfiguration.framework框架

    Customize

    (non)

    Installation

    You should copy below files to your projects. 添加对应的框架,然后将以下两个文件拖到你的项目中即可

    FBNetworkReachability.h
    FBNetworkReachability.m
    SystemConfiguration.framework
    

    License

    see LICENSE file

     
  • 相关阅读:
    树形结构基础
    最长公共子序列
    四 过滤模式 map Only
    三 概要模式 2) MR倒排索引、性能分析、搜索干扰词。
    三 概要模式 1)数值概要 (单词计数记录计数最大值/最小值/计数平均值、中位数、标准差)
    一 梳理 从 HDFS 到 MR。
    个人学习源码的 HBase误区的总结 与 架构图
    15 hbase 学习(十五)缓存机制以及可以利用SSD作为存储的BucketCache
    13 hbase源码系列(十三)缓存机制MemStore与Block Cache
    HBase 系统架构
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4271568.html
Copyright © 2011-2022 走看看