title: Swift: Cant access let outside a method
body: <p>I have a question.</p>
  
  <p>I have the following method:</p>
  
  <pre><code>   func CheckJSON(json: JSON) {
          for data in json["index"].arrayValue {
  
              let title = data["name"].stringValue
              let body = data["profil"].stringValue
              let obj = ["title": title, "body": body]
              objects.append(obj)
  }
  
  
          tableView.reloadData()
      }
  </code></pre>
  
  <p>I would like to access the constant 'body' outside of my function and also outside of this file.</p>
  
  <p>I already tried it like this: </p>
  
  <pre><code>   func CheckJSON(json: JSON) -&gt; String {
      for data in json["index"].arrayValue {
  
          let title = data["name"].stringValue
          let body = data["profil"].stringValue
          let obj = ["title": title, "body": body]
          objects.append(obj)
  
  
  
      }
  
      tableView.reloadData()
      return body
  }
  </code></pre>
  
  <p>But i get the Error:</p>
  
  <blockquote>
    <p>Use of unresolved identifier 'body'</p>
  </blockquote>
  
  <p>Any idea? </p>