3

I'm new in iOS and Swift development, and i'm not used to manage the network reachability in my usual programs.

I found AFNetworking and Alamofire which are great frameworks to ease the API calls in iOS.

But i have difficulties to figure out how to make some requests to wait until network is back if i'm loosing it. Typically during session login or getting some json lists or downloading images.

Do you have some tutorials or examples i can rely on to improve my knowledge and be able to build a strong application resilient to network availability ?

Sylver
  • 2,285
  • 3
  • 29
  • 40
  • you could use the Alamofire .suspend() and .resume() methods as soon as you detect a loss of network? – longbow Feb 12 '15 at 17:18
  • Yes, I was thinking about that along the reachability manager of afnetworking. But i'm not really sure on how i should do that and if i can be sure that no request will be lost if i'm doing that ? And so i should also notify the controller maybe to do or display smth during the wait. I was looking for some elaborate examples actually. – Sylver Feb 12 '15 at 17:21

2 Answers2

2

now Alamofire has just included a Network status listener

https://github.com/Alamofire/Alamofire/pull/1053

Marco Pappalardo
  • 935
  • 6
  • 23
0

Alamofire now has a network reachability manager

This is from their github page -

let manager = NetworkReachabilityManager(host: "your.server.url.com")

manager?.listener = { status in print("Network Status Changed: \(status)") }

manager?.startListening()

Tushar Koul
  • 2,830
  • 3
  • 31
  • 62
  • 1
    Please do not [duplicate your answers](http://stackoverflow.com/a/37705418/2415822). Instead, flag to close questions as duplicates if you believe they are asking the same thing – JAL Jun 08 '16 at 16:24