Post

Replies

Boosts

Views

Activity

Swift App Debugger Not Working?
When my Swift program stops at a breakpoint values for some of the variables that appear to be available for inspection are shown, but most are not. The variables themselves are listed, but no values are shown when I look at them. The code snippet is the addItem function in the default ContentView for a Swift project, somewhat modified for my particular purpose. Stopping at a breakpoint in this function I am able to see the value for the variable zz, but properties of the Ledger and LedgerEntry structures seem to have no values. I can inspect them, but they all show 'Value: None'. Even those values that have been explicitly defined are not displayed. Here's what I see when I print the debugger's description of these couple of properties: Printing description of newEntry._ix: (PennyJar.LedgerEntry._SwiftDataNoType) _ix = {} Printing description of newLedger._type: (PennyJar.Ledger._SwiftDataNoType) _type = {} I have read what I can find on the forums, and I've checked all the suggested build parameters, which all seem to be correctly indicating a Debug build with no Optimization. I would really appreciate any guidance from someone who knows these tools... Thanks in advance! @Model final class Ledger { var id = UUID() var name: String var type: String var entries: [LedgerEntry] init(name: String) { self.name = name self.type = "" self.entries = [] } } @Model final class LedgerEntry { let id = UUID() var ix: Int = 0 var date: String var chkno: String var payee: String var category: String var debit: Float var credit: Float init(ledger: Ledger) { self.ix = 0 self.date = "1/21/24" self.chkno = "" self.payee = "" self.category = "" self.debit = 0 self.credit = 0 } } private func addItem() { withAnimation { let zz = 27 let newLedger = Ledger(name: "New Ledger") let newEntry = LedgerEntry(ledger: newLedger) newEntry.payee = "Initial Balance" newEntry.ix = 1 newLedger.entries.append(newEntry) modelContext.insert(newLedger) } }
2
0
402
Jan ’24
Clearing Swift App Data
Swift Newbie here... I've been coding for a very long time, but never on Apple platform until now. I'm walking my way through tutorials and examples, and trying this and that. Today I'm trying to learn how to clear extraneous SwiftData schemas from the persistent data store on my MacOS platform. I created an App named 'Xyz' that's just the sample App that is created when one chooses File->New->Project..., built it and ran it. It supports creation of a persistent list of items, and after learning what I could from the code I deleted the project folder and moved on to the next 'lesson'. Now I find that the items that were created when I ran the Xyz App are still out there, somewhere. I need to remove them, but I cannot seem to find any info on where they are stored or how to remove them. In my experience, discarding extraneous application data is a fundamental task normally performed over and over during early stages of application development. I understand the Migration Path concept, but that seems way too complex for Apps that are nothing more than learning environments... Help?
2
0
639
Jan ’24