Socialcademy 4 Error No exact matches in reference to static method 'buildExpression'

Hello,

I’m working on Socialcademy 4, but when I get to the Before we continue, we’ll need to fix another compiler error. I’ll come, I’ll move on to the solution. The error does not go away for me. I copied the code, but this doesn’t help. Does anyone have another solution?

code Loadable

import Foundation

enum Loadable {
case loading
case error(Error)
case loaded(Value)

var value: Value? {
    get {
        if case let .loaded(value) = self {
            return value
        }
        return nil
    }
    set {
        guard let newValue = newValue else { return }
        self = .loaded(newValue)
    }
}

}

extension Loadable where Value: RangeReplaceableCollection {
static var empty: Loadable { .loaded(Value())}
}

extension Loadable: Equatable where Value: Equatable {
static func == (lhs: Loadable, rhs: Loadable) → Bool {
switch (lhs, rhs) {
case (.loading, .loading):
return true
case let (.error(error1), .error(error2)):
return error1.localizedDescription == error2.localizedDescription
case let (.loaded(value1), .loaded(value2)):
return value1 == value2
default:
return false
}
}
}

code PostList

import SwiftUI

struct PostList: View {

@StateObject var viewmodel = PostsViewModel()
@State private var searchText = ""
@State private var showNewPostForm = false

var body: some View {
    NavigationView {
        Group {
            switch viewmodel.posts {
            case .loading:
                ProgressView()
            case .error(error):
                VStack (alignment: .center, spacing: 10) {
                    Text("Cannot load Posts")
                        .font(.title2)
                        .fontWeight(.semibold)
                        .foregroundColor(.primary)
                }
            case .empty:
                Text("No Posts")
            case let .loaded(posts):
                List(posts) { post in
                    if searchText.isEmpty || post.contains(searchText) {
                        PostRow(post: post)
                    }
                }
                .searchable(text: $searchText)
            }
            .searchable(text: $searchText)
            .navigationTitle("Posts")
            .toolbar {
                Button {
                    showNewPostForm = true
                } label: {
                    Label("New Post", systemImage: "square.and.pencil")
                }
            }
            .sheet(isPresented: $showNewPostForm) {
                NewPostForm(createAction: viewmodel.makeCreateAction())
            }
        }
        .onAppear {
            viewmodel.fetchPosts()
        }
    }
}

}

#Preview {
PostList()
}

Sadly i have the same issue, it dissappeared after i moved on, but it came back.

Hey @matthijsvo

Dis error go away after completing the 4 section.
I’m now at section 6 and dis error will coming 7 or 8 times.

Hi @sebastiaanel,
my solving was simple, i referred to viewmodel.makeCreateAction(), but i did not implement that method yet. So i had to create that method in the viewmodel and then it all worked.

matthijs

Hey I am sure you fixed that issue by now but maybe in future somebody will profit from the solution.

The problem is that one of your viewModel.X does not reference to a correct method in PostViewModel (likely you have a spelling mistake)
easiest way to find out is to check all viewModel.X in your PostList and check if every link has the same color, if the syntax link is wrong that’s a give away. alternative check the spelling of every viewModel.X and every method in PostViewModel