I have the following code for PreviewProvider for TransactionsListView.swift:
struct TransactionsListView_Previews: PreviewProvider {
static var previews: some View {
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
let transaction = NPTransaction(context: context)
transaction.date = Date()
transaction.income = true
transaction.type = "morning"
transaction.value = 1200
transaction.notes = "notes"
return TransactionsListView(filter: true, startDate: Date()).environment(\.managedObjectContext, context)
}
}
Preview is not showing up. There is a message that Build Succeeded and there is no error message, but Canvas is empty. What am I doing wrong?
P.s. I am using CoreData and have 1 entity called NPTransaction which has 5 attributes: date, income, notes, type, value.