I am using xcode version 8.
I want to create an app that shows images in a UITableView
. That image fetched from the url. And also want to know how to store and fetch from json.
Can anyone tell me
I am using xcode version 8.
I want to create an app that shows images in a UITableView
. That image fetched from the url. And also want to know how to store and fetch from json.
Can anyone tell me
If you're making a simple app then you can use NSURL for both these tasks, or you can take a look at either:
AFNetworking: https://github.com/AFNetworking/AFNetworking
This has a very simple extension on UIImageView for async download of photos as well as json support, or you can use
Alamofire: https://github.com/Alamofire/Alamofire
This is a networking library written purely in Swift if you're a swift enthusiast, with a lot of modern swift constructs and methods.
func JSONParsing() {
let url1 = URL(string: "yourURLHere")
let request1 = URLRequest(url: url1!)
let session1 = URLSession.shared
let task1 = session1.dataTask(with: request1, completionHandler: {
(data1 : Data?, response1 : URLResponse?, error1 : Error?) in
if error1 != nil
{
print("\n Data Could Not Be Fetch. \n")
}
else
{
let jsonp = try! JSONSerialization.jsonObject(with: data1!, options: JSONSerialization.ReadingOptions.mutableContainers) as! NSDictionary
//iterate dictionary and array
}