Last active
January 24, 2018 09:31
-
-
Save codejockie/8549d8c02c0d55849cd407246a7db4b8 to your computer and use it in GitHub Desktop.
Just a reusable code
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
| // | |
| // Coin.swift | |
| // Crypto Price Tracker | |
| // | |
| // Created by Kennedy on 22/01/2018. | |
| // Copyright © 2018 Kennedy. All rights reserved. | |
| // | |
| import Foundation | |
| class Coin { | |
| var id: String? | |
| var name: String? | |
| var symbol: String? | |
| var rank: String? | |
| var price_usd: String? | |
| var price_btc: String? | |
| var h_volume_usd: String? | |
| var market_cap_usd: String? | |
| var available_supply: String? | |
| var total_supply: String? | |
| var max_supply: String? | |
| var percent_change_1h: String? | |
| var percent_change_24h: String? | |
| var percent_change_7d: String? | |
| var last_updated: String? | |
| let json = JSON.init(parseJSON: "[{\"name\" : \"Bitcoin\", \"id\" : \"bitcoin\", \"price_usd\" : \"10554.2\", \"percent_change_24h\" : \"-9.42\", \"symbol\" : \"BTC\"}, {\"name\" : \"Ethereum\", \"id\" : \"ethereum\", \"price_usd\" : \"965.272\", \"percent_change_24h\" : \"-8.98\", \"symbol\" : \"ETH\"}, {\"name\" : \"Ripple\", \"id\" : \"ripple\", \"price_usd\" : \"1.1983\", \"percent_change_24h\" : \"-14.02\", \"symbol\" : \"XRP\"}, {\"name\" : \"Bitcoin Cash\", \"id\" : \"bitcoin_cash\", \"price_usd\" : \"1580.9\", \"percent_change_24h\" : \"-11.28\", \"symbol\" : \"BCH\"}, {\"name\" : \"Cardano\", \"id\" : \"cardano\", \"price_usd\" : \"0.53791\", \"percent_change_24h\" : \"-12.47\", \"symbol\" : \"ADA\"}]") | |
| formatTickersData(json: json) | |
| if let url = URL(string: baseImageUrl + ticker["symbol"].string!) { | |
| DispatchQueue.global().async { | |
| let data = try? Data(contentsOf: url) | |
| DispatchQueue.main.async { | |
| cell.coinImageView.image = UIImage(data: data!) | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment