title: How to make MacOS app url request to text field?
body: <p>I need to make an app on MacOS with a single button and a single text field, so when I press the button , particular data (mySubstring) from internet will appear in text box. I've tried to do that in Swift Playground , it works fine and here is the code:</p>
  <pre><code>import Foundation
  
  
  
  var info: String = &quot;&quot;
  let mySubstring = &quot;&quot;
  let myString = String(mySubstring)
  
  
  var request = URLRequest(url: URL(string: &quot;https://api.openweathermap.org/data/2.5/weather?id=1502026&amp;appid=df10ddc41c923a4f0e93ffc67631f0c5&quot;)!)
  request.httpMethod = &quot;GET&quot;
  
  let task = URLSession.shared.dataTask(with: request)
  { data, response, error in
  
  info = String(decoding: data!, as: UTF8.self)
  
      let index = info.index(info.startIndex, offsetBy: 16)
      let endindex = info.index(info.startIndex, offsetBy: 22)
      let mySubstring = info[index...endindex]
   
  
  print(mySubstring)
      
  }
  
  
  task.resume()
  </code></pre>
  <p>but when I try to gather it all to a Project. I need to do in App exactly what I wrote, thereafter I will extend my tasks.</p>
  <p>Thanks in advance !</p>