title: how to load image From Rest Api Into View did Load Method Using Swift 3
body: <p>I want to load image in View did load method without use of Tableview or collectionView , I have URL of Wordpress Rest Api , I tried to load Image using SwiftyJson , I got Row Values of All Images But Image is not Able to Load  I Found fatal error: Index out of range, please help me </p>
  
  <pre><code>override func viewDidLoad() {
              super.viewDidLoad()
  
  
          let url = NSURL(string: "  ")
  
          let session = URLSession(configuration: URLSessionConfiguration.default)
  
          let task = session.dataTask(with: URLRequest(url: url! as URL)) {(data,response , error) -&gt; Void in
  
              if (error == nil)
              {
  
                  let swiftyJSON = JSON(data!)
                  let entrylevel = swiftyJSON["guid"].arrayValue
  
                  print("\(String(describing: entrylevel))")
                  let imagearray = entrylevel[0]["rendered"].string!
  
                  let imageurl = NSURL(string:imagearray)
  
                  if let imagedata = NSData(contentsOf: imageurl! as URL)
  
                  {
                      self.img.image = UIImage(data: imagedata as Data)
                      print("image load")
  
                  }       
  
              }        
  
          }
          task.resume()
      }
  </code></pre>
  
  <p>and here is my rest api </p>
  
  <blockquote>
    <p>[{"id":1509 "date":"2018-02-15T13:33:22",
    "date_gmt":"2018-02-15T13:33:22" "<strong>guid</strong>": {
    "<strong>rendered</strong>":"http://thenewschef.com/wp-content/uploads/2018/02/startup.jpeg"
    }</p>
  </blockquote>