I need to get notified when connectivity changes during app usage. I have imported Reachability.h .m files to my Swift project, and bridged it by adding #include "Reachability.h"
.
In Apple's Reachability example project an observer is set up to get notified when connectivity changes. How can I set it up in Swift?
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:) name:kReachabilityChangedNotification object:nil];
There is no equivalent observer in Swift. Swift has property observers like willSet
and didSet
.