I have some html code that I have receive from json. Now I have to write this html code to html document that is in my project and than show it in webView. How can I write my HTML code to my html file in my project.
Here is in my content variable I have HTML code.
func getArticles() {
//let id = "1018"
let url = "http://www.salemkz.kz/inc/API/getArticles.php?idArticle=170"
print(url)
URLSession.shared.dataTask(with: URL(string: url)!) { (data, response, error) in
if (error != nil) {
print(error!.localizedDescription)
}
else {
let jsons = try! JSONSerialization.jsonObject(with: data!, options: .allowFragments) as! [String: AnyObject]
if let results = jsons["result"] as? [[String: AnyObject]] {
//print("got Result", results)
for result in results {
let content = result["content"] as? String
print(content!)
}
}
}
}.resume()
}
And I have to write this code to this html file (named "articles-1.html") :
How to do this ???