让playground执行异步操作
by 伍雪颖
import
UIKit
import
XCPlayground
XCPSetExecutionShouldContinueIndefinitely(continueIndefinitely:
true)
let
url =
NSURL(string:
"http://httpbin.org/get")
let
getTask =
NSURLSession.sharedSession().dataTaskWithURL(url!)
{
(data,response,error) ->
Void
in
let dictionary:
AnyObject? =
NSJSONSerialization.JSONObjectWithData(data, options:
nil, error:
nil)
println(dictionary)
}
getTask.resume()
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-11-09 05:18:32