Skip to content

Instantly share code, notes, and snippets.

@shahryarjb
Last active February 28, 2017 15:33
Show Gist options
  • Save shahryarjb/b6307d8f40d75aba71c9ef0735402ed6 to your computer and use it in GitHub Desktop.
Save shahryarjb/b6307d8f40d75aba71c9ef0735402ed6 to your computer and use it in GitHub Desktop.
swift 3 -json
let url = URL(string: "http://localhost:8888/iosnotic/index.php?option=com_helloworld&view=helloworld&action=select&id=0")
let setion = URLSession.shared
let request = NSMutableURLRequest(url: url!)
request.httpMethod = "POST"
request.timeoutInterval = TimeInterval(10)
let postString = "name=22"
request.httpBody = postString.data(using: String.Encoding.utf8)
let task = setion.dataTask(with: request, completionHandler: { (NSData, response, error) in
let task = setion.dataTask(with: request, completionHandler: { (NSData, response, error) in
do {
let records = try JSONSerialization.jsonObject(with: NSData!, options: JSONSerialization.ReadingOptions.mutableContainers) as! NSArray
for record in records {
let blogViewsCont = StructBlogsView()
blogViewsCont.task_id = Int(record["task_id"] as! String)
blogViewsCont.task_title = record["task_title"] as! String
blogViewsCont.task_desc = record["task_desc"] as! String
blogViewsCont.last_modify_time = record["last_modify_time"] as! String
blogViewsCont.task_img = record["task_img"] as! String
blogViewsCont.category = record["category"] as! String
blogViewsCont.profileauthername = record["profileAutherName"] as! String
blogViewsCont.profileimgauther = record["profileImgAuther"] as! String
blogViewsCont.timetest = record["timetest"] as! String
blogViewsCont.postlike = record["likecontent"] as! String
blogViewsCont.postcoment = record["coment"] as! String
blogViewsCont.posthit = record["hit"] as! String
blogViewsCont.tumb1 = record["imgeboud"] as! String
blogViewsCont.tumb2 = record["imgeboud1"] as! String
blogViewsCont.tumb3 = record["imgeboud2"] as! String
// shop collection views
blogViewsCont.shopingMainPagePrice = record["price"] as! String
blogViewsCont.shopingMainPageImg = record["picshop"] as! String
AppDelegate.blogViewsConts.append(blogViewsCont)
self.iDcheack.append(blogViewsCont.task_id)
}
DispatchQueue.main.async(execute: {
self.collectionViewShop.reloadData()
})
}catch {
// cheack error
print("Json catch error")
} // end do try catch
})
task.resume()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment