diff LazyBear/Views/Profile/Helpers/WatchlistCreator.swift @ 417:5f21f7c23c5e

Add comments and clean code
author Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com>
date Fri, 11 Jun 2021 11:37:42 +0200
parents 0a4c399170c4
children 4effac4733b0
line wrap: on
line diff
--- a/LazyBear/Views/Profile/Helpers/WatchlistCreator.swift	Wed Jun 09 20:26:28 2021 +0200
+++ b/LazyBear/Views/Profile/Helpers/WatchlistCreator.swift	Fri Jun 11 11:37:42 2021 +0200
@@ -56,8 +56,7 @@
                     Button("Cancel", action: { self.showCancelAlert = true })
                 }
             }
-            // Show delete list alert
-            .alert(isPresented: $showCancelAlert) {
+            .alert(isPresented: $showCancelAlert) {  /// Show alert when the user tries to exit the view without saving the new watchlist
                 Alert(
                     title: Text("Your watchlist won't be saved"),
                     message: Text("This action can't be undo"),
@@ -66,8 +65,7 @@
                 )
             }
         }
-        // Show alert when watchlist name is empty
-        .alert(isPresented: $watchlistNameIsEmpty) {
+        .alert(isPresented: $watchlistNameIsEmpty) {  /// Show alert when the user tries to save the watchlist without a name
             Alert(
                 title: Text("Give a name to your new watchlist"),
                 message: Text("Try My portfolio, Favourites, ..."),
@@ -82,7 +80,7 @@
     
     /*
      Search company in array and get the index -> Delete company at
-     this index from the array
+     this index from the array (Core Data)
      */
     private func remove(_ company: SearchResponse) {
         let index = watchlistCreatorClass.companies.firstIndex(of: company)