-1

CoreData:

Item

  • userName
  • userSurname

Fetch request

@FetchRequest(
        sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)],
        animation: .default)
    private var items: FetchedResults<Item>

How can I apply last added userName in Items value to var X ?

Kirill
  • 11
  • 4

1 Answers1

0

Thanks to @vadian

var x = items.last?.userName ?? ""

Kirill
  • 11
  • 4