Skip to content

Instantly share code, notes, and snippets.

@romyilano
Last active April 9, 2019 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romyilano/bee152e9983f5e851a3495b45c9e9779 to your computer and use it in GitHub Desktop.
Save romyilano/bee152e9983f5e851a3495b45c9e9779 to your computer and use it in GitHub Desktop.
import Foundation
// async swift playground
import PlaygroundSupport
// https://min-api.cryptocompare.com/data/all/coinlist
let allCoinsPath = "/data/all/coinlist"
class CryptoApi {
static let host = "min-api.cryptocompare.com"
static let allCoinsPath = "/data/all/coinlist"
var allCoinsUrl: URL? = {
var urlComponents = URLComponents()
urlComponents.scheme = "https"
urlComponents.host = CryptoApi.host
urlComponents.path = CryptoApi.allCoinsPath
return urlComponents.url
}()
}
let cryptoApi = CryptoApi()
if let allCoinsUrl = cryptoApi.allCoinsUrl {
print(allCoinsUrl.absoluteString)
}
PlaygroundPage.current.needsIndefiniteExecution = true
// brushing up on url components
//
class CryptoApi {
static let host = "min-api.cryptocompare.com"
static let allCoinsPath = "/data/all/coinlist"
var allCoinsUrl: URL? = {
var urlComponents = URLComponents()
urlComponents.scheme = "https"
urlComponents.host = CryptoApi.host
urlComponents.path = CryptoApi.allCoinsPath
return urlComponents.url
}()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment