LocalConnection.h
1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// LocalConnection.h
// RealReachability
//
// Created by Dustturtle on 16/1/9.
// Copyright (c) 2016 Dustturtle. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#define GLocalConnection [LocalConnection sharedInstance]
/// We post self to this notification,
/// then you should invoke currentLocalConnectionStatus method to fetch current status.
extern NSString *const kLocalConnectionChangedNotification;
/// After start observering, we post this notification once,
/// you may invoke currentLocalConnectionStatus method to fetch initial status.
extern NSString *const kLocalConnectionInitializedNotification;
typedef NS_ENUM(NSInteger, LocalConnectionStatus)
{
LC_UnReachable = 0,
LC_WWAN = 1,
LC_WiFi = 2
};
@interface LocalConnection : NSObject
/// Newly added property for KVO usage:
/// maybe you only want to observe the local network is available or not.
@property (nonatomic, assign) BOOL isReachable;
+ (instancetype)sharedInstance;
/**
* Start observering local connection status.
*/
- (void)startNotifier;
/**
* Stop observering local connection status.
*/
- (void)stopNotifier;
/**
* Return current local connection status immediately.
*
* @return see enum LocalConnectionStatus
*/
- (LocalConnectionStatus)currentLocalConnectionStatus;
@end