0

I'd like to have a Swift function called by OS X or iOS when the network connection is back up after being down. For instance, when airplane mode has been disabled. My app should be aware of this instantly and restart using the network right away.

I found this solution, but it would involve polling, and I want to avoid this.

Community
  • 1
  • 1
RooSoft
  • 1,481
  • 2
  • 17
  • 32
  • 1
    https://github.com/ashleymills/Reachability.swift – tbilopavlovic Jun 14 '16 at 14:23
  • You can register a callback function which is called when the reachability status changes, see e.g. http://stackoverflow.com/questions/30786883/swift-2-unsafemutablepointervoid-to-object or http://stackoverflow.com/a/27142665/1187415. – Martin R Jun 14 '16 at 14:24
  • user1941284: Working flawlessly with low energy consumption and clean code... Add this as an answer and I confirm it. – RooSoft Jun 14 '16 at 15:35

1 Answers1

0

I am now using github.com/ashleymills/Reachability.swift to resolve that issue.

RooSoft
  • 1,481
  • 2
  • 17
  • 32