I am getting the error in console “[FormViewModel] Cannot submit: objectNotFound(“posts/31FC5737-D8E3-49B1-9874-1D381F164179”)”. I am getting this error when I am trying to post a photo to a post in the app. Also when I try to take a picture for a post the camera just freezes after pressing the capture button. My FormViewModel code is
import Foundation
@MainActor
@dynamicMemberLookup
class FormViewModel<Value>: ObservableObject {
typealias Action = (Value) async throws -> Void
@Published var value: Value
@Published var error: Error?
@Published var isWorking = false
subscript<T>(dynamicMember keyPath: WritableKeyPath<Value, T>) -> T {
get { value[keyPath: keyPath] }
set { value[keyPath: keyPath] = newValue }
}
private let action: Action
init(initialValue: Value, action: @escaping Action) {
self.value = initialValue
self.action = action
}
nonisolated func submit() {
Task {
await handleSubmit()
}
}
private func handleSubmit() async {
isWorking = true
do {
try await action(value)
} catch {
print("[FormViewModel] Cannot submit: \(error)")
self.error = error
}
isWorking = false
}
}
Looking for some guidance on this please let me know if you have any pointers as to what could be wrong. If you need to see more code, just let me know? But I am pretty sure my code matches what is on the Codecademy solution… kinda upset and stuck here. Please help a brother out. Thank you in advance!