The name of the class you showed is Products, not ProductManager. That is why the compiler can't find ProductManager.
Does the error go away if you change the name of the class to ProductManager or if you change ProductManager to Products in the .onAppear block?
You also need to create an instance of your class to call the function.
.onAppear {
let manager = ProductManager()
manager.loadProduct()
}
In a real SwiftUI app you would add a property to the view.
@StateObject manager = ProductManager()
My examples assume you changed the name of the class from Products to ProductManager.
I recommend taking a course like Hacking with Swift's 100 Days of SwiftUI to learn SwiftUI. A course like that would help you deal with problems like the one you asked about here.
https://www.hackingwithswift.com/100/swiftui
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: