Following How to limit the number of results in a FetchRequest in SwiftUI I created a FetchRequest to get the latest billing number.
My code looks like this
var billNo: FetchRequest<Payments>
...
init() {
let request: NSFetchRequest<Payments> = Payments.fetchRequest()
request.fetchLimit = 1
request.sortDescriptors = [NSSortDescriptor(key: "rechnungsNummer", ascending: false)]
billNo = FetchRequest<Payments>(fetchRequest: request)
}
But how on earth do I get access to the values of billNo.rechnungsNummer
? billNo.wrappedValue.first?.rechnungsNummer
ist always nil
.
Or has it all changed the last two years?
btw: it's all inside a view. ;)