Skip to content

Instantly share code, notes, and snippets.

@Jerrot
Jerrot / URLSession Calls in Swift 4
Created January 9, 2019 09:40 — forked from cmoulton/URLSession Calls in Swift 4
URLSession Calls in Swift 4
func makeGetCall() {
// Set up the URL request
let todoEndpoint: String = "https://jsonplaceholder.typicode.com/todos/1"
guard let url = URL(string: todoEndpoint) else {
print("Error: cannot create URL")
return
}
let urlRequest = URLRequest(url: url)
// set up the session

Rules

Attributes

Identifier Enabled by default Supports autocorrection
attributes Disabled No

Attributes should be on their own lines in functions and types, but on the same line as variables and imports.