azamsharp/BudgetApp

BudgetApp crashing due to uncaught exception

Opened this issue · 0 comments

the BudgetApp is not previewing the BudgetDetailView Swift UI file. The application is unexpectedly crashing.

The crash report for this preview error mentions an "unrecognised selector sent to "BudgetCategory" instance. The issue might be related to attempting to access a "BudgetCategory" instance for which the "name" property is not defined or has a value of 'nil'.

The error might also be related to property changes detected by Swift UI during view updates. There are two lines of code in the BudgetDetailView Swift file that set the values of the @State variables "name" and "total" to "". Commenting out these lines did not change the error crash report.

The only logical reason why the application is crashing might be because the "name" property is being accessed by an instance of "BudgetCategory" in the BudgetDetailView file, but it seems the property does not exist or is not being implemented for some reason.

The BudgetDetailView preview provider struct takes in a "budgetCategory" object of the type "BudgetCategory" as a parameter. This BudgetDetailView file is being set as a destination view in the BudgetListView file. In the BudgetListView, the variable "BudgetCategoryResults" holds all the budget categories stored in the CoreData context retrieved by a fetch request. Maybe the issue is related to how the BudgetCategory entities are managed or fetched. If the issue is related to this, "budgetCategory" objects whose "name" property is not defined properly is being used as a parameter for the BudgetDetailView file. I will look into this in detail to check whether correct data is being sent to the destination view.

I modified the code in the BudgetListView file to make it easier to set up the list of budget categories with the destination view being the BudgetDetailView file. I am attaching a picture of this new code.

BudgetApp Bug Report