Created
June 21, 2017 01:52
-
-
Save towry/0c780e49c52b543b532954f1651ce343 to your computer and use it in GitHub Desktop.
swift: request a web page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
import Foundation | |
import PlaygroundSupport | |
URLCache.shared = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil) | |
let url = URL(string: "http://www.baidu.com") | |
let task = URLSession.shared.dataTask(with: url!) {data, response, error in | |
guard let data = data, error == nil else { return } | |
print(NSString(data: data, encoding: String.Encoding.utf8.rawValue)) | |
} | |
#if ABC | |
print("hahahahah") | |
#endif | |
print("begin") | |
task.resume() | |
PlaygroundPage.current.needsIndefiniteExecution = true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment