Kann ich irgendwie eine synchrone HTTP-Anfrage über NSURLSession
in Swift machen?Kann ich irgendwie eine synchrone HTTP-Anfrage über NSURLSession in Swift machen
kann ich eine asynchrone Anforderung über den folgenden Code tun:
if let url = NSURL(string: "https://2ch.hk/b/threads.json") {
let task = NSURLSession.sharedSession().dataTaskWithURL(url) {
(data, response, error) in
var jsonError: NSError?
let jsonDict = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: &jsonError) as [String: AnyObject]
if jsonError != nil {
return
}
// ...
}
task.resume()
}
Aber was synchrone Anforderung?
Vielen Dank im Voraus.
Check this out http://stackoverflow.com/questions/21198404/nsurlsession-with-nsblockoperation-and-queues – Ian