Hi all,
I hope someone can point out what I am doing wrong here. Been working on iExpense and thought to push myself a little further on this project so I tried the whole MVVM model achectecture (not sure if im doing it right) and split the views up for a cleaner code structure. Splitting the views was not an issue, but for some reason I cannot get the main view (ExpView.swift) to update when I delete an expense from BusinessExpenseSheet.swift / PersonalExpense.Sheet.swift.
I added the onDelete directly in the viewModel of the class and on the view itself, so that way there is no two instances of a deleting items that could be conflicting data. Also, added an onChange modifer to ExpView.swift for each Button Label that holds the total value for both personal/business expense. That when a change is detected, to update the view.
Everything works fine, besides the fact when I delete an item from Personal or Business, the ExpView doesn't capture the changes of the deleting items. It only captures the added values as I add more expenses.
I tried to changing it from a @StateObject to a @EnvironmentObject to no avail.
If someone can point me the right direction, I would greatly appreciate it. Beens smashing my head on this for the past few days.
GitHub Repo: https://github.com/EyeOfHorus396/iExpense