Last active
September 18, 2016 17:45
-
-
Save michaelteter/2e6017e7df94394e55746f139144d682 to your computer and use it in GitHub Desktop.
Reminder of the syntax of Alamofire 4 JSON request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remember to add to Info.plist | |
// App Transport Security Settings / Dictionary | |
// Allow Arbitrary Loads / Boolean / YES | |
// (or to be safer, use the Exception Domains subkey to be specific about which domains are allowed non-secure) | |
import Alamofire | |
// ... | |
func example() { | |
let url = URL(string: "http://pokeapi.co/api/v2/type/3/")! | |
Alamofire.request(url).responseJSON { response in | |
switch response.result { | |
case .success: | |
print("/ JSON returned in makeRequest: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv") | |
print(response.result.value) | |
print("\\ JSON returned in makeRequest: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^") | |
break | |
case .failure(let error): | |
print(error) | |
break | |
} | |
} | |
// You'll notice this occurs in the console LONG before the request completes. | |
print("~~~~~~ below request ~~~~~~~~") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment