finlay ☀
finlay ☀
TSDThe Swift Den
Created by finlay ☀ on 8/18/2023 in #swift-development
Nondescript crash in my SwiftData app when trying to access a dictionary
I'm making an app for a school project in SwiftUI and SwiftData. It's a habit tracker and I have a SwiftData class for persisting basic habits. Where the problem started is that I'm trying to implement a way to track when a certain habit was completed. I deleted my existing instances of the class and added a dictionary under self.isCompleted as [Date:Bool] (so 3rd of August = true etc.) I then made a function in the HabitView (where you can see the details of the habit) that checks if the current date in the dictionary is true and if so doesn't show the option to complete the habit. Problem is now that whenever I make a habit, and go into view it, the app instantly crashes with the only error being a "SIGTERM". I thought it was crashing because it was trying to check something that wasn't there (empty dictionary bc new habit) but I've tried compensating for that and it's still crashing with the all-ambiguous error. Anyone know what I can do now? Will provide code upon request if needed. Honestly at this point I might just kinda try something completely different for keeping track of completion.
6 replies