title: iOS Swift downloading files
body: <p>I need to download a file, which is located on the server. I have an URL for it like:   <a href="http://www.myhosting.com/1.txt" rel="nofollow">http://www.myhosting.com/1.txt</a>
  I need to download it to my iOS device or, at least, read text from it. 
  My project is on SWIFT.
  Now I am using a code below:</p>
  
  <pre><code>let requestURL: NSURL = NSURL(string: "http://www.myhosting.com/1.txt")!
          let urlRequest: NSMutableURLRequest = NSMutableURLRequest(URL: requestURL)
          let session = NSURLSession.sharedSession()
          let task = session.dataTaskWithRequest(urlRequest) {
              (data, response, error) -&gt; Void in
  
              let httpResponse = response as! NSHTTPURLResponse
              let statusCode = httpResponse.statusCode
  
              if (statusCode == 200) {
                  self.dtlbl.text = "Everyone is fine, file downloaded successfully."
  
              }
          }
  
          task.resume()
  </code></pre>
  
  <p>But it doesn't work. My app just closing up after running this code. 
  I tried to read it, but it was unluck too..</p>
  
  <p>Please, need any help!
  Dont know what to do. 
  One more think - I SHOULDN'T use any side frameworks. </p>