title: swift, how to retrieve string from another function?
body: <p>I want to be able to retrieve this string in one of my functions... but thats not really the problem I've done that before. But this time instead the string is defined as and if let inside the function and can't be found anywhere else inside the function. I want to be able to use that same value (fileloaction) a string outside of that function but it can't be found.
  Here's my code:</p>
  
  <pre><code>    func extract_json(data:NSString)
  {
      var parseError: NSError?
      let jsonData:NSData = data.dataUsingEncoding(NSASCIIStringEncoding)!
      let json: AnyObject?
      do {
          json = try NSJSONSerialization.JSONObjectWithData(jsonData, options: [])
      } catch let error as NSError {
          parseError = error
          json = nil
      }
      if (parseError == nil)
      {
          if let works_list = json as? NSArray
          {
              for (var i = 0; i &lt; works_list.count ; i++ )
              {
                  if let fileList = works_list[i] as? NSDictionary
                  {
                      if let fileName = fileList["filename"] as? String
                      {
                          TableData1.append(fileName)
  
                          //if let country_code = country_obj["post_text"] as? String
                          //{
                              //TableData1.append(country_name + " [" + country_code + "]")
                          //}
                      }
  
                      this is the function 
                      if let filelocation = fileList["filelocation"] as? String
                      {
                          TableData1.append(filelocation)
  
  
                      }
  
                      if let mime = fileList["mime"] as? String
                      {
                          TableData1.append(mime)
  
  
                      }
                  }
              }
          }
      }
  
      do_table_refresh();
  }
  </code></pre>
  
  <p>That string fileloaction cant be found anywhere else in that function so for that reason I can't use it anywhere else that I'd need to like here:</p>
  
  <pre><code>        override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
  
          extract_json(filelocation)
  
         // selectedFileLocation = "http://192.168.1.14:8080/Works/uploads/1445557983_putty.docx"
  
          selectedFileLocation = filelocation
  
  
          if(segue.identifier == "detailView") {
  
              let vc = segue.destinationViewController as! DisplayWorksViewController
              vc.selectedFileLocation = selectedFileLocation
              vc.selectedLabel = selectedLabel
              print("selectedFileLocation = \(vc.selectedFileLocation)")
          }
      }
  </code></pre>