mercredi 8 janvier 2020

SwiftUI ForEach does not compile with if block inside - Bug or am I doing something wrong?

I am getting an error that I don't understand. I am not sure if it is a compiler error or if I am doing something wrong?

Inside a swiftUI View I have a list showing elements from core data (Figure 1). In the example below I replaced the t.name with "yo" for some undefined reason 😅.

Anyway, the tasks is a fetch request from Core Data:

@FetchRequest(entity: Task.entity(), sortDescriptors: []) var tasks: FetchedResults<Task>

FIGURE 1: Works fine to build and run the app. enter image description here

FIGURE 2: Does not work to build and run the app. enter image description here

Please help me understand what I am doing wrong or is this a compiler bug? Why can't I add the if block inside the ForEach? I can provide more information if needed. Thanks!

Aucun commentaire:

Enregistrer un commentaire