Post

Replies

Boosts

Views

Activity

Reply to Delete items of an class's array from a view... (?)
If you have @StateObject var items: ItemModel = .init() in your ContentView, you should pass this model to the other views, for example @ObservedObject var items: ItemModel in your ItemView. Also you should have in your Observable class, items.append(Item(id: id, category: [category], image: image)) not Piercing(...). Currently you create a new and different ItemModel every time you show ItemView
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’23
Reply to Cannot convert value of type '[Lesson]' to expected argument type 'Binding<C>' and Generic parameter 'C' could not be inferred
ForEach(lessons) { lesson in ...} is not a "normal" for loop. It is a View that needs to have other Views in it, not procedural code like you have. Put this type of code (using a "normal" for loop`), for example in .onAppear{ lessons.forEach{ lesson in ...} } Note that NavigationView is deprecated, use NavigationStack instead.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’24