Created
July 4, 2025 11:15
-
-
Save jacobsapps/afc5faf9fa285dcf6ac4a6d6c9b51cc6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import SwiftData | |
| @Observable | |
| final class CardCollectionViewModel { | |
| private(set) var cards: [Card] = [] | |
| private let database: CardDatabase | |
| init() { | |
| self.database = try! CardDatabase() | |
| cards = try! database | |
| .read(sortBy: SortDescriptor<CardEntity>(\.createdAt)) | |
| .compactMap { $0.toCard() } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment