MattKersey / Oncology-Helper

An iOS app meant to provide patients with tools for navigating appointments with oncologists.
1 stars 0 forks source link

Fix edge case where there are no entries in JSON file #4

Closed MattKersey closed 4 years ago

MattKersey commented 4 years ago

App encounters fatal error when all appointments have been deleted

MattKersey commented 4 years ago

Seems as though this is an issue with ForEach and List, which take a constant number of elements. There is an option in the ForEach loop called .onDelete that allows you to bypass this. A possible solution would be to create a single view that has the ForEach loop for every other view, but what it shows is controlled by a set of variables (eg, you could have a bool that specifies upcoming appointments vs all, a variable that specifies what kind of element to display, one that takes an integer id and only displays that single item, etc)

MattKersey commented 4 years ago

Changed design so that there is a single ForEach loop (in HomePage). Now it works.