Mercurial > public > lazybear
view LazyBear/Views/Profile/ProfileView.swift @ 346:80bfa88c6b0f
Implementing Prop API
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sun, 11 Apr 2021 19:55:47 +0200 |
parents | fde2b30c719e |
children | d402bfa367c2 |
line wrap: on
line source
// // ProfileView.swift // LazyBear // // Created by Dennis Concepción Martín on 4/4/21. // import SwiftUI //struct ProfileView: View { // @ObservedObject var profileData = ProfileData() // @Environment(\.managedObjectContext) private var moc // @FetchRequest(entity: WatchlistCompany.entity(), sortDescriptors: []) // var watchlistCompanies: FetchedResults<WatchlistCompany> // // var body: some View { // NavigationView { // List { // Text("Hello World") // Button("Save company", action: addCompany) // Button("Delete company", action: removeCompany) // Button("Request", action: {profileData.get(watchlistCompanies)}) // Button("Print watchlist", action: {print(watchlistCompanies.map {$0.symbol})}) // } // .navigationTitle("My profile") // .navigationBarTitleDisplayMode(.inline) // } // } // // // REMOVE IN PRODUCTION // private func addCompany() { // let watchlistCompany = WatchlistCompany(context: moc) // watchlistCompany.symbol = "FB" // watchlistCompany.name = "Facebook Inc" // watchlistCompany.watchlist = "MyWatchlist" // do { // try moc.save() // print("Company saved") // } catch { // print(error.localizedDescription) // } // } // // private func removeCompany() { // let symbols = watchlistCompanies.map { $0.symbol } // let index = symbols.firstIndex(of: "aapl") // let company = watchlistCompanies[index!] // moc.delete(company) // do { // try moc.save() // print("Company deleted") // } catch { // // Error // } // } //} // //struct ProfileView_Previews: PreviewProvider { // static var previews: some View { // ProfileView() // } //}