iOS/Swift : How to manage network versatility with Alamofire

百般思念 提交于 2019-12-23 21:05:50

问题


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 ?


回答1:


now Alamofire has just included a Network status listener

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




回答2:


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()



来源:https://stackoverflow.com/questions/28483577/ios-swift-how-to-manage-network-versatility-with-alamofire

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!