This file contains 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
//A few basic UIColor's | |
let red = UIColor(red: 255/255, green: 0, blue: 0, alpha: 1.0) | |
let darkGrey = UIColor(red: 100/255, green: 100/255, blue: 100/255, alpha: 1.0) | |
let cyan = UIColor(red: 0, green: 255/255, blue: 255/255, alpha: 1.0) |
This file contains 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
let red = UIColor(r: 255, g: 0, b: 0, alpha: 1.0) | |
let darkGrey = UIColor(r: 100, g: 100, b: 100, alpha: 1.0) | |
let cyan = UIColor(r: 0, g: 255, b: 255, alpha: 1.0) |
This file contains 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
convenience init(r: Int, g: Int, b: Int, alpha: CGFloat = 1.0) { | |
let red = CGFloat(r)/255 | |
let green = CGFloat(g)/255 | |
let blue = CGFloat(b)/255 | |
self.init(red: red, green: green, blue: blue, alpha: alpha) | |
} |
This file contains 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
import UIKit | |
extension UIColor { | |
convenience init(r: Int, g: Int, b: Int, alpha: CGFloat) { | |
let red = CGFloat(r)/255 | |
let green = CGFloat(g)/255 | |
let blue = CGFloat(b)/255 | |
self.init(red: red, green: green, blue: blue, alpha: alpha) | |
} |
This file contains 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
convenience init(r: Int, g: Int, b: Int, alpha: CGFloat = 1.0) { | |
func intToColorFloat(int: Int) -> CGFloat { | |
let divisor: CGFloat = 255 | |
return CGFloat(int) / divisor | |
} | |
self.init(red: intToColorFloat(r), green: intToColorFloat(g), blue: intToColorFloat(b), alpha: alpha) | |
} |
This file contains 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
let red = UIColor(r: 255, g: 0, b: 0) | |
let darkGrey = UIColor(r: 100, g: 100, b: 100) | |
let cyan = UIColor(r: 0, g: 255, b: 255) |
This file contains 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
let apiURL = URL(string: "https://min-api.cryptocompare.com/data/pricehistorical?fsym=ETH&tsyms=USD") |
This file contains 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
private func makeValueGETRequest(url: URL, completion: @escaping (_ value: NSNumber?) -> Void) { | |
let request = URLSession.shared.dataTask(with: url) { (data, response, error) in | |
// TODO: Get the data and return it | |
} | |
request.resume() | |
} |
This file contains 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
guard let data = data, error == nil else { | |
completion(nil) | |
print(error?.localizedDescription ?? "") | |
return | |
} |
This file contains 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
private func formatAsCurrencyString(value: NSNumber?) -> String? { | |
let formatter = NumberFormatter() | |
formatter.locale = Locale(identifier: "en_US") | |
formatter.numberStyle = .currency | |
// TODO: Unwrap the number as a formatted currency String | |
} |
OlderNewer