Fabian Boulegue
Fabian Boulegue

Reputation: 6608

Alamofire and SwiftyJSON

I currently try to get a json but i always get a error

   Alamofire.request(.GET, "http://api.androidhive.info/contacts/").responseJSON { (req, res, json) -> Void in
            let swiftyJsonVar = JSON(json.value!)
            print(swiftyJsonVar)
        }

enter image description here

Upvotes: 0

Views: 82

Answers (3)

ItsMeMihir
ItsMeMihir

Reputation: 294

try this

Alamofire.request("http://api.androidhive.info/contacts/").responseJSON { (responseObject) -> Void in            
        if responseObject.result.isSuccess {
            let resJson = JSON(responseObject.result.value!)
            print(resJson)
        }
    }

Upvotes: 0

Fabian Boulegue
Fabian Boulegue

Reputation: 6608

Alamofire.request(.GET, "http://api.androidhive.info/contacts/").responseJSON { (responseData) -> Void in
            let swiftyJsonVar = JSON(responseData.result.value!)
            print(swiftyJsonVar)

Upvotes: 0

vadian
vadian

Reputation: 285059

The error message reveals that the return type of the closure is a single object rather than three.

Two suggestions to get the proper syntax quickly:

  • use code completion.
  • -click on the symbol or look at Quick Help (⌥⌘2) to read the documentation.

In your case the request method returns one response object

Upvotes: 1

Related Questions