0

We're trying to test an Alomofire GET request using a Playground. It's working but we can't see the JSON returned by the request in the Playground. How can you do this? Note clicking the right arrows in the screen shot doesn't show any JSON.

Playground:

enter image description here

The request's JSON response:

{
  "userId": 1,
  "id": 2,
  "title": "qui est esse",
  "body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla"
}
Marcus Leon
  • 50,921
  • 112
  • 279
  • 413

1 Answers1

1

Your playground ended before the request could complete. Pause it indefinitely by setting needsIndefiniteExecution = true:

import UIKit
import SwiftyJSON
import Alamofire
import XCPlayground

Alamofire.request(.GET, "http://jsonplaceholder.typicode.com/posts/2")
    .responseJSON { response in
        let json = JSON(data: response.data!)
        print(json)
    }

XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
Code Different
  • 73,850
  • 14
  • 125
  • 146
  • Thanks. I believe this API has changed per stackoverflow.com/a/33536290/4096655 - which worked. Thanks for the help. – Marcus Leon Mar 31 '16 at 00:45