Я пытаюсь загрузить имя с индексом 1, но он не работает (CollectionView пуст).
CoreData :
LoadData:
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
let managedContext = appDelegate.persistentContainer.viewContext
let fetchRequestTag = NSFetchRequest<NSManagedObject>(entityName: "Tag")
let PreValue = 1
let predicate = NSPredicate(format: "index == %i", PreValue)
fetchRequestTag.predicate = predicate
do {
tagItems = try managedContext.fetch(fetchRequestTag)
} catch let error as NSError {
print("Could not fetch. \(error), \(error.userInfo)")
}
TagCollectionView.reloadData()
TagCollectionView.selectItem(at: NSIndexPath(item: 0, section: 0) as IndexPath, animated: false, scrollPosition: [])
for data in tagItems {
print("\(data.value(forKey: "name") as! String as Any), \(NSKeyedUnarchiver.unarchiveObject(with: data.value(forKeyPath: "index") as! Data) as! Int)")
}