Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //1
- self.sendNetworkOperation(
- params: ["Token":"Bearer aaaaaaaaaa","limit": 100],
- completion: { (res) in
- switch res.0{ //6
- case true:
- //success
- break
- case false:
- //error
- break
- }
- })
- func isReachable() -> Bool {
- let reachability = Reachability()! //3
- if reachability.isReachable{ //4
- return true
- }
- return false
- }
- func sendNetworkOperation(
- params: Dictionary<String,Any>,
- completion: ((Bool,String?)->())){
- //2
- if self.isReachable(){
- //5
- //send operation
- completion(true, nil)
- } else {
- //5
- completion(false, "Error, network is not reachable")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment