So I have an .onRecieve
method
.onReceive(model2.$postsById) { postById in
print(\"MODEL2 \\(self.model2.postsById)\")
}
try this:
struct Album: View {
var post:Post
var post2:[PostById]
var body: some View {
VStack {
Text("Title: ").bold()
+ Text("\(post!.title)")
ImageView(withURL: "http://localhost:8000/\(post!.path.replacingOccurrences(of: " ", with: "%20"))")
Text("Description: ").bold()
+ Text("\(post!.description)")
if post2.count > 0 {
List(self.post2.filter { i in i.album_id == post.id }) { post in
Text("\(post.name ?? "title")")
print(post2)
}
}
I think you want to declare post2 as
@Binding var post2:[PostById]
And then pass in
Album(post: post, post2: self.model2._postsById)
Which is what $
does, but you can't use that here.