Skip to content

Instantly share code, notes, and snippets.

@javalnanda
Created April 30, 2017 19:57
Show Gist options
  • Select an option

  • Save javalnanda/1dbb4bd364338f5528ed80aabe26d66b to your computer and use it in GitHub Desktop.

Select an option

Save javalnanda/1dbb4bd364338f5528ed80aabe26d66b to your computer and use it in GitHub Desktop.
func fetchData(){
UIApplication.shared.isNetworkActivityIndicatorVisible = true
let apiUrl = "https://raw.githubusercontent.com/javalnanda/AlamofireObjectMapperSample/master/AOMsample.json"
Alamofire.request(apiUrl).validate().responseArray(keyPath: "result") { (response: DataResponse<[Project]>) in
UIApplication.shared.isNetworkActivityIndicatorVisible = false
switch response.result {
case .success:
self.projects = response.result.value ?? []
for project in self.projects {
print(project.name)
}
case .failure(let error):
print(error)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment