Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.58 KB | None | 0 0
  1. class StockListViewModel {
  2.    
  3.     var stocks = [StockViewModel]()
  4.    
  5.     func fetchAllStocks() {
  6.        
  7.         HTTPClient().getAllStocks(urlString: "https://silicon-rhinoceros.glitch.me/stocks") { result in
  8.             DispatchQueue.main.async {
  9.                 switch result {
  10.                     case .success(let stocks):
  11.                         self.stocks = stocks.map(StockViewModel.init)
  12.                     case .failure(let error):
  13.                         print(error.localizedDescription)
  14.  
  15.                 }
  16.             }
  17.            
  18.         }
  19.        
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement