title: AFNetworking and Swift
body: <p>I'm trying to get a JSON response using Swift.</p>
  
  <p>I sniffed the request and response -> everything ok. However the return value is always <code>nil</code>.</p>
  
  <pre><code>let httpClient = AppDelegate.appDelegate().httpRequestOperationManager as AFHTTPRequestOperationManager;
  
  let path = "/daten/wfs";
  let query = "?service=WFS&amp;request=GetFeature&amp;version=1.1.0&amp;typeName=ogdwien:AMPELOGD&amp;srsName=EPSG:4326&amp;outputFormat=json".stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding);
  
  func successBlock(operation: AFHTTPRequestOperation!, responseObject: AnyObject!) {
      println("JSON: " + "\(responseObject)")
  }
  
  func errorBlock(operation: AFHTTPRequestOperation!, error:NSError!) {
      println("Error: " + error.localizedDescription)
  }
  
  let urlString = "\(path)" + "/" + "\(query)"
  println("urlString: " + httpClient.baseURL.absoluteString + urlString)
  </code></pre>
  
  <p>I also tried it this way:</p>
  
  <pre><code>httpClient.GET(urlString, parameters: nil,
      success: { (operation: AFHTTPRequestOperation!, responseObject: AnyObject!) -&gt; Void in
          println("Success")
          println("JSON: " + "\(responseObject)")
      },
      failure:{ (operation: AFHTTPRequestOperation!, error:NSError!) -&gt; Void in
          println("Failure")
      })
  </code></pre>
  
  <p>... But the <code>responseObject</code> always seems to be <code>nil</code></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Maybe the reason is the possible wrong initialisation in my <code>AppDelegate</code>:</p>
  
  <pre><code>var httpRequestOperationManager: AFHTTPRequestOperationManager? // JAVA SERVER Client
  
  class func appDelegate() -&gt; AppDelegate {
      return UIApplication.sharedApplication().delegate as AppDelegate
  }
  
  func configureWebservice() {
      let requestSerializer = AFJSONRequestSerializer()
      requestSerializer.setValue("1234567890", forHTTPHeaderField: "clientId")
      requestSerializer.setValue("Test", forHTTPHeaderField: "appName")
      requestSerializer.setValue("1.0.0", forHTTPHeaderField: "appVersion")
  
      let responseSerializer = AFJSONResponseSerializer()
  
      AFNetworkActivityIndicatorManager.sharedManager().enabled = true
  
      // ##### HTTP #####
      let baseURL = NSURL(string: "http://data.wien.gv.at");
      httpRequestOperationManager = AFHTTPRequestOperationManager(baseURL: baseURL))
  
      httpRequestOperationManager!.requestSerializer = requestSerializer
      httpRequestOperationManager!.responseSerializer = responseSerializer
  }
  </code></pre>
  
  <p>Any suggestions what I'm doing wrong?</p>