I’ve a property in a mannequin that Is initially empty as string array (userReports) that may maintain the customers’ notes. However after I try to append values to it and show it, it nothing updates. Racking my mind understanding knowledge persistence total so im unsure if im going about this the correct approach.
@Mannequin
remaining class ActiveStash {
var substanceClass: String
var substance: String
var weight: UInt
var substanceCost: UInt?
var StashDescription: String?
var date: Date
var unit: String
var dosages: Int?
var userReports: [String]?
init(substanceClass: String, substance: String, weight: UInt, substanceCost: UInt? = nil, StashDescription: String? = nil, date: Date, unit: String, dosages: Int? = nil, userReports: [String]? = nil) {
self.substanceClass = substanceClass
self.substance = substance
self.weight = weight
self.substanceCost = substanceCost
self.StashDescription = StashDescription
self.date = date
self.unit = unit
self.dosages = dosages
self.userReports = userReports
}
}
Perform so as to add the customers’ report back to the mannequin
func addReport() {
guard !inputReport.isEmpty else {
return
}
var updatedReports = stashed.userReports ?? []
updatedReports.append(inputReport)
strive? modelContext.save()
dismiss()
}
}
How I am trying to show the textual content after the perform name from one other web page
struct StashLinkView: View {
@Surroundings(.modelContext) var modelContext
let stashed: ActiveStash
@State non-public var viewSelect = "Utilization"
var viewName = ["Usage", "Report"]
let currencySymbol = Locale.present.currencySymbol ?? ""
@State non-public var isSheetShown = false
var physique: some View {
VStack {
/// different code
}
// unsure im im doing this block appropriately
VStack {
if let userReports = stashed.userReports, !userReports.isEmpty {
ForEach(userReports, id: .self) { report in
VStack {
Textual content(report)
}
}
} else {
Textual content("No Notes")
}
}
Redmi Note 13 5G (Arctic White, 6GB RAM, 128GB Storage) | 5G Ready | 120Hz Bezel-Less AMOLED | 7.mm Slimmest Note Ever | 108MP Pro-Grade Camera
₹16,999.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)POCO C65 Pastel Green 8GB RAM 256GB ROM
₹7,999.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Ambrane Unbreakable 3A Fast Charging 1.5m Braided Type C Cable for Smartphones, Tablets, Laptops & other Type C devices, 480Mbps Data Sync, Quick Charge 3.0 (RCT15A, Black)
₹129.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)POCO C65 Pastel Blue 8GB RAM 256GB ROM
₹7,999.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Portronics Luxcell Wireless Mini 10k 10000mAh 15W Magnetic Wireless Fast Charging Smallest Power Bank with 22.5 Wired Output Compatible with iPhone 12 & Above & Other QI Enabled Devices(Black)
₹1,469.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Ambrane Unbreakable 3A Fast Charging 1.5m Braided Type C Cable for Smartphones, Tablets, Laptops & other Type C devices, 480Mbps Data Sync, Quick Charge 3.0 (RCT15A, Black)
₹129.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Portronics My Buddy K Portable Laptop Stand with Adjustable Height, Foldable, OverHeating Protection for Laptops & MacBooks (Grey)
₹498.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Dell MS116 Wired Optical Mouse, 1000DPI, LED Tracking, Scrolling Wheel, Plug and Play
₹305.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)amazon basics Type A to Micro USB Braided Cable | 3A/18W Fast Charging and 480 Mbps Data Transfer Speed | 1.2m, Tangle Free Cable
₹109.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Oakter Mini UPS for 12V WiFi Router Broadband Modem | Backup Upto 4 Hours | WiFi Router UPS Power Backup During Power Cuts | UPS Broadband Modem | Current Surge & Deep Discharge Protection
₹1,099.00 (as of May 14, 2024 14:12 GMT +00:00 - More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Auto Amazon Links: No products found.