Learn Courses My Dashboard

"Instance member" error

Hi there,
I am receiving a Instance member 'features' cannot be used on type 'DataModel'; did you mean to use a value of this type instead? error on the PageView(pages: DataModel.features.map { FeatureCard(product: $0) }) line.
features is apparently defined in my DataModel() file: var features: [Product] { products.filter { $0.isFeatured } }
I am modifying the Apple SwiftUI Tutorial code.
this is my view:

struct SearchView: View {
                @StateObject var model = DataModel()
                @State private var searchText = ""
                @State private var showSheet = false
                var body: some View {
                    NavigationStack {
                        List {
                            ForEach(filteredProducts, id: \.self) { product in
                                NavigationLink {
                                } label: {
                                    PageView(pages: DataModel.features.map { FeatureCard(product: $0) })
                                        .aspectRatio(3 / 2, contentMode: .fit)
                                        .onTapGesture {showSheet = true}
                    .searchable(text: $searchText, prompt: "Tap to Search")
                    .sheet(isPresented: $showSheet) {
                        ProductDetail(product: <#Product#>)
                var filteredProducts: [Product] {
                    if searchText.isEmpty {
                        return model.products
                    } else {
                        return model.products.filter {
                            $0.name.lowercased().contains(searchText.lowercased()) ||
        struct SheetView: View {
            let product: Product
            var body: some View {
                VStack {

and if you need it this is my Product() file:

import Foundation
import SwiftUI

struct Product: Hashable, Codable, Identifiable {
    var id: Int
    var name: String
    var flavour: String
    var description: String
    var isFeatured: Bool
    var category: Category
    enum Category: String, CaseIterable, Codable {
        case drink = "Drink"
        case yoghurt = "Yoghurt"
    var image: String
    private var imageName: Image {
    var image2: String
    private var image2Name: Image {
    var image3: String
    private var image3Name: Image {
    var featureImage: Image? {
            isFeatured ? Image(image) : nil

Change this:

to this:


features is a property on an instance of DataModel but you are calling it as if it were a static property of the type itself.

What is FeatureCard?

(edit) Good pickup Patrick.

(edit 2)
Hmmm, even if you change it to this as Patrick is suggesting:

PageView(pages: model.features.map { FeatureCard(product: $0) })

I’m still curious as to what FeatureCard() is.

FeatureCard() is just the name of the view I use to represent my product’s image: https://developer.apple.com/tutorials/swiftui/interfacing-with-uikit#Create-a-View-to-Represent-a-UIPageViewController
I’m following the Apple tutorial and am using their UIKit image carousel.
Thanks for the speedy solution.