This file contains 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
class PodcastTableViewController: UITableViewController, DataParserObserver { | |
var podcasts = [Podcast]() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.podcasts = [Podcast]() | |
let dataParser = HttpRequesting() | |
dataParser.httpGetPodCasts(parserObserver: self) |
This file contains 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
func httpGetApi () { | |
let parameters: Parameters = ["username": "username", "password": "password"] | |
Alamofire.request("url", 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") |
This file contains 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
JSON - | |
[[{"Title":"testi27","Original filename":"rainforest.mp3","Description":"joo","Tags":"testi\r\n\u00e4\u00e4ni\r\njoo","Category":"","Sound Type":"soundscapes","Creation date":"2016-10-27 12:20:42","File extension":"mp3","File size(KB)":"154.8","Created by":"podcast","Collection name":"ylepodcast","Collection ID":"5","Download link":"http:lii.fi"}],[{"Title":"Adrenaline","Original filename":"Adrenaline.mp3","Description":"there goes descriptions","Tags":"Category:Music\r\nMusic","Category":"","Sound Type":"soundscapes","Location - longitude":"www.imgur.com","Length (sec)":"132","Creation date":"2016-10-27 13:29:28","File extension":"mp3","File size(KB)":"5301.0","Created by":"podcast","Collection name":"Testi","Collection ID":"17","Download link":"http:lii.fi"}]] | |
Swift - | |
Alamofire.request("link_to_json/", method: .get, parameters:parameters) | |
.responseJSON{response in | |
if let json = response.result.value { | |
if let array = json as? [Any] { | |
This file contains 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
if let array = json as? [Any] { | |
for object in array { | |
print(object) | |
} | |
} |
NewerOlder