title: Swift 3 GET request unable to display returned values
body: <p>Trying to make a GET request with Swift 3 and Xcode8 but not having much luck outputting data I received back from my GET request to the Main.Storyboard either in a label or a text field all I get is all the returned JSON in the console in Xcode8.</p>
  
  <p>There is a snippet of JSON that is returned with my request in Xcode8 which I have attached below for reference. I can access "@encoding" and "@version" but everything else is not able to be accessed and I am not able to figure out why. If this was a web based setup I could just declare a variable and then set it equal to someObject.petfinder[1].shelters etc...</p>
  
  <p>This is my code that is making the request, taking a zipcode from an input field and then building the url and returning it which then is using NSDictionary. </p>
  
  <p>The error I get back in the console is:</p>
  
  <p>"fatal error: unexpectedly found nil while unwrapping an Optional value
  2017-06-20 12:15:49.392688 PetFinder[47445:9486946] fatal error: unexpectedly found nil while unwrapping an Optional value"</p>
  
  <pre><code> // SEND HTTP GET REQUEST
  
      // DEFINE SERVER SIDE SCRIPT URL
      let scriptUrl = "https://api.petfinder.com/"
      let methodType = "shelter.find"
      let apiKey = "?key=0000000000000000000000000"
      let urlWithParams = scriptUrl + methodType + apiKey + "&amp;location=\(shelterZip)&amp;format=json"
  
  
      // CREATE NSURL Object
      let myUrl = NSURL(string: urlWithParams)
  
      // CREATE URL REQUEST
      let request = NSMutableURLRequest(url:myUrl! as URL);
  
      // REQUEST METHOD - GET / POST
      request.httpMethod = "GET"
  
      // RUN HTTP REQUEST
      let task = URLSession.shared.dataTask(with: request as URLRequest) {
          data, response, error in
  
          if error != nil {
              print("error \(error!)")
                  return
          }
  
      // PRINT OUT RESPONSE STRING
      let responseString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
      print("responseString = \(String(describing: responseString))")
  
  
      // CONVERT RECEIVED JSON TO NSDictionary
          do {
              if let convertedJsonIntoDict = try JSONSerialization.jsonObject(with: data!, options: []) as? NSDictionary {
  
                  // Print out dictionary
                  print(convertedJsonIntoDict)
  
                  // Get value by key
                  let shelterName = convertedJsonIntoDict["shelters"] as? [String: Any]
  
                  for(key, pair) in convertedJsonIntoDict {
                      print("--&gt;\(key) \(pair)")
                  }
                  print(shelterName!)
  
              }
          } catch let error as NSError {
              print(error.localizedDescription)
          }
  
      }
  
      task.resume()
  
      }
  </code></pre>
  
  <p>// SNIPPET OF RETURNED JSON FROM THE TOP</p>
  
  <pre><code> {
  "@encoding" = "iso-8859-1";
  "@version" = "1.0";
  petfinder =     {
      "@xmlns:xsi" = "http://www.w3.org/2001/XMLSchema-instance";
      "@xsi:noNamespaceSchemaLocation" = "http://api.petfinder.com/schemas/0.9/petfinder.xsd";
      header =         {
          status =             {
              code =                 {
                  "$t" = 100;
              };
              message =                 {
              };
          };
          timestamp =             {
              "$t" = "2017-06-20T16:15:49Z";
          };
          version =             {
              "$t" = "0.1";
          };
      };
      lastOffset =         {
          "$t" = 25;
      };
      shelters =         {
          shelter =             (
                              {
                  address1 =                     {
                  };
                  address2 =                     {
                  };
                  city =                     {
                      "$t" = Nebraska;
                  };
                  country =                     {
                      "$t" = US;
                  };
                  email =                     {
                      "$t" = "wooffun@woof.net";
                  };
                  fax =                     {
                  };
                  id =                     {
                      "$t" = NE117;
                  };
                  latitude =                     {
                      "$t" = "13.004";
                  };
                  longitude =                     {
                      "$t" = "-31.449";
                  };
                  name =                     {
                      "$t" = WOOF COMPANY;
                  };
                  phone =                     {
                  };
                  state =                     {
                      "$t" = NE;
                  };
                  zip =                     {
                      "$t" = 68001;
                  };
              },
  </code></pre>