Created
February 20, 2019 05:52
-
-
Save paulw11/b728b5dfad8bc6f4c63e568c202bd7e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ViewController.h" | |
#import <Network/Network.h> | |
@interface ViewController () | |
@property (strong,nonatomic) nw_path_monitor_t pathMonitor; | |
@end | |
@implementation ViewController | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
// Do any additional setup after loading the view, typically from a nib. | |
self.pathMonitor = nw_path_monitor_create(); | |
nw_path_monitor_set_update_handler(self.pathMonitor, ^(nw_path_t _Nonnull path) { | |
NSLog(@"Network path changed"); | |
bool isExpensive = nw_path_is_expensive(path); | |
NSLog(@"Path is expensive - %d",isExpensive); | |
}); | |
nw_path_monitor_start(self.pathMonitor); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment