Skip to content

Instantly share code, notes, and snippets.

@paulw11
Created February 20, 2019 05:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulw11/b728b5dfad8bc6f4c63e568c202bd7e5 to your computer and use it in GitHub Desktop.
Save paulw11/b728b5dfad8bc6f4c63e568c202bd7e5 to your computer and use it in GitHub Desktop.
#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