Mercurial > public > lazybear
diff LazyBear/Views/Search/Helpers/SearchedCompanyItem.swift @ 425:4effac4733b0
Changing keys from API responses
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Wed, 16 Jun 2021 13:46:01 +0200 |
parents | 5f21f7c23c5e |
children | c6913f0ce46e |
line wrap: on
line diff
--- a/LazyBear/Views/Search/Helpers/SearchedCompanyItem.swift Sun Jun 13 19:40:42 2021 +0200 +++ b/LazyBear/Views/Search/Helpers/SearchedCompanyItem.swift Wed Jun 16 13:46:01 2021 +0200 @@ -12,14 +12,14 @@ @Environment(\.managedObjectContext) private var moc @FetchRequest(entity: WatchlistCompany.entity(), sortDescriptors: []) - var watchlistCompany: FetchedResults<WatchlistCompany> + var watchlistCompanies: FetchedResults<WatchlistCompany> @State private var showingWatchlistSelector = false var body: some View { HStack { Button(action: { self.showingWatchlistSelector = true }) { - let watchlistSymbols = watchlistCompany.map { $0.symbol } + let watchlistSymbols = watchlistCompanies.map { $0.symbol } if watchlistSymbols.contains(company.symbol!) { Image(systemName: "star.fill") .foregroundColor(.yellow) @@ -60,7 +60,7 @@ */ private func generateButtons() -> [ActionSheet.Button] { var actionButtons = [ActionSheet.Button]() - let watchlists = Set(watchlistCompany.map { $0.watchlist }) + let watchlists = Set(watchlistCompanies.map { $0.watchlistName }) for watchlistName in watchlists { actionButtons.append( @@ -78,11 +78,11 @@ /* When the user taps the watchlist -> save the company to CoreData */ - private func addCompany(_ symbol: String, _ name: String, _ watchlist: String) { + private func addCompany(_ symbol: String, _ name: String, _ watchlistName: String) { let watchlistCompany = WatchlistCompany(context: moc) watchlistCompany.symbol = symbol watchlistCompany.name = name - watchlistCompany.watchlist = watchlist + watchlistCompany.watchlistName = watchlistName do { try moc.save() print("Company saved")