I'm new to Swift, my task is to get data from GET request and present its data on UI. Below is my code:
let credentialData = "\(user):\(password)".dataUsingEncoding(NSUTF8StringEncoding)!
let base64Credentials = credentialData.base64EncodedStringWithOptions([])
let headers = ["Authorization": "Basic \(base64Credentials)"]
Alamofire.request(.GET, myUrl, headers: headers)
.responseJSON{ JSON in
if let jsonResult = JSON as? Array<Dictionary<String, String>> {
let title = jsonResult[0]["title"]
print(title)
}
}
I'm able to get data with request but I don't know how to parse JSON
object in some format (probably json array) that can be later used to present in TableView. Please help
Data example:
[ { "title": "Sony", "content": "Tech content", "image": "http://google.com/content/device.jpg?06" }, { "title": "Nexus", "content": "Nexus 6 is a new beginning", "image": "http://google.com/content/device.jpg?01" } ]