中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

iOS網(wǎng)絡(luò)監(jiān)測

2018-07-20    來源:open-open

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用

在網(wǎng)絡(luò)應(yīng)用中,需要對用戶設(shè)備的網(wǎng)絡(luò)狀態(tài)進(jìn)行實(shí)時監(jiān)控,有兩個目的:

(1)讓用戶了解自己的網(wǎng)絡(luò)狀態(tài),防止一些誤會(比如怪應(yīng)用無能)

(2)根據(jù)用戶的網(wǎng)絡(luò)狀態(tài)進(jìn)行智能處理,節(jié)省用戶流量,提高用戶體驗(yàn)

WIFI\3G網(wǎng)絡(luò):自動下載高清圖片

低速網(wǎng)絡(luò):只下載縮略圖

沒有網(wǎng)絡(luò):只顯示離線的緩存數(shù)據(jù)

蘋果官方提供了一個叫Reachability的示例程序,便于開發(fā)者檢測網(wǎng)絡(luò)狀態(tài)

https://developer.apple.com/library/ios/samplecode/Reachability/Reachability.zip

二、監(jiān)測網(wǎng)絡(luò)狀態(tài)

Reachability的使用步驟

添加框架SystemConfiguration.framework

 

添加源代碼

包含頭文件

#import "Reachability.h"

#import "QYViewController.h"

#import "Reachability.h"

@interface QYViewController ()

@property (nonatomic, strong) Reachability *conn;

@end


@implementation QYViewController


- (void)viewDidLoad

{

    [super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkStateChange) name:kReachabilityChangedNotification object:nil];

         self.conn = [Reachability reachabilityForInternetConnection];

         [self.conn startNotifier];

    

}


- (void)dealloc

{

    [self.conn stopNotifier];

    [[NSNotificationCenter defaultCenter] removeObserver:self];

}


- (void)networkStateChange

{

    [self checkNetworkState];

}


標(biāo)簽: 代碼 開發(fā)者 網(wǎng)絡(luò)

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:C#驗(yàn)證給定的字符串是否為數(shù)字

下一篇:C#驗(yàn)證給定的字符串形式的日期是否合法