Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #import "ViewController.h"
  2. #import <Network/Network.h>
  3.  
  4. @interface ViewController ()
  5. @property (strong,nonatomic) nw_path_monitor_t pathMonitor;
  6. @end
  7.  
  8. @implementation ViewController
  9.  
  10.  
  11. - (void)viewDidLoad {
  12. [super viewDidLoad];
  13. // Do any additional setup after loading the view, typically from a nib.
  14.  
  15. self.pathMonitor = nw_path_monitor_create();
  16. nw_path_monitor_set_update_handler(self.pathMonitor, ^(nw_path_t _Nonnull path) {
  17. NSLog(@"Network path changed");
  18. bool isExpensive = nw_path_is_expensive(path);
  19. NSLog(@"Path is expensive - %d",isExpensive);
  20. });
  21. nw_path_monitor_start(self.pathMonitor);
  22. }
  23.  
  24.  
  25. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement