title: How to get data from NXOAuth2Request response
body: <p>I'm writing my first iOS app. It includes API calls through OAuth2Client.</p>
  
  <p>The problem is when calling the AdvAPI getUser function. A GET request is made through NXOAuth2Request which deals with the response data in responseHandler and variable result is set to an NSDictionary. The result however is not accessible outside the XOAuth2Request function. How can I get the result and return it from getUser?</p>
  
  <p>Thanks!</p>
  
  <pre><code>import Foundation
  
  class AdvAPI {
  var store : NXOAuth2AccountStore
  var account : NXOAuth2Account?
  
  init(){
      self.store = NXOAuth2AccountStore.sharedStore() as NXOAuth2AccountStore
      self.store.setClientID(
          "test",
          secret: "test",
          authorizationURL: NSURL.URLWithString("http://localhost:3000/oauth/authorize"),
          tokenURL: NSURL.URLWithString("http://localhost:3000/oauth/token"),
          redirectURL: NSURL.URLWithString("http://localhost:3000/oauth/connect"),
          forAccountType: "AdventureApp"
      )
  
      self.account = self.store.accountsWithAccountType("AdventureApp")[0]
  }
  
  
  func getUser(parameters : NSDictionary=[String: AnyObject]()) -&gt; NSDictionary {
  
      NXOAuth2Request.performMethod("GET",
          onResource: NSURL.URLWithString("http://localhost:3000/api/v1/me"),
          usingParameters: parameters,
          withAccount: self.account,
          sendProgressHandler: nil,
          responseHandler: {(response: NSURLResponse?, responseData: NSData?, error: NSError?) in
              var jsonError: NSError
              var result = NSJSONSerialization.JSONObjectWithData(responseData, options: NSJSONReadingOptions.MutableContainers, error: nil) as NSDictionary
          }
      )
      return result
  }
  
  }
  </code></pre>