In the file InventoryManager when I return Inventory appears: Missing argument for parameter 'from' in call also in ContentView
InventoryManager.swift
import Foundation
class InventoryManager { static let shared = InventoryManager()
private let key = "inventory"
func saveInventory(_ inventory: Inventory) {
if let encoded = try? JSONEncoder().encode(inventory) {
UserDefaults.standard.set(encoded, forKey: key)
}
}
func loadInventory() -> Inventory {
if let data = UserDefaults.standard.data(forKey: key),
let decoded = try? JSONDecoder().decode(Inventory.self, from: data) {
return decoded
}
return Inventory() // <-- HERE
}
}
ContentView.swift
import Foundation import SwiftUI
struct ContentView: View { @State private var inventory: Inventory = Inventory() // <-- HERE
var body: some View {
TabView {
... etc