Skip to content

Instantly share code, notes, and snippets.

@arto-heino
Created November 14, 2016 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arto-heino/c02d83b44e89b3446468280d79a36420 to your computer and use it in GitHub Desktop.
Save arto-heino/c02d83b44e89b3446468280d79a36420 to your computer and use it in GitHub Desktop.
func httpGetApi () {
let parameters: Parameters = ["username": "username", "password": "password"]
Alamofire.request("addr", method: .post, parameters:parameters, encoding: JSONEncoding.default)
.responseJSON{response in
if let json = response.result.value as? [String: String] {
self.setApiKey(apiKey: json["api_key"]!)
}else{
self.setMessage(statusMessage: "Ei toimi")
}
}
}
func httpGetPodCasts (parserObserver: DataParserObserver) {
httpGetApi()
let parameters: Parameters = ["key": self.getApiKey(), "category": ""]
var podcasts: [Podcast] = [Podcast]()
.....
}
In tableview,
override func viewDidLoad() {
super.viewDidLoad()
self.podcasts = [Podcast]()
let dataParser = HttpRequesting()
dataParser.httpGetPodCasts(parserObserver: self)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment