[ad_1]
I’ve a CoreData base with 6 rows in it.
I na ViewController, the info is displayed in a UITable, after I choose a row within the desk, the didSelectRow
lists 6 rows. Which can be all of the rows.
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
caches = CoreData.getCaches()
print ("Quantity (caches.depend)") // offers 6
performSegue(withIdentifier: "Choose", sender: nil)
}
When the Segue is executed the prepareForSegue is executed. Now the identical command outcomes with the worth 7.
override func put together(for segue: UIStoryboardSegue, sender: Any?) {
caches = CoreData.getCaches()
print ("Quantity (caches.depend)") // offers 7
}
I believe that one thing within the background is occurring, however i am unable to discover out what.
Under is the static technique for reference:
static func getCaches() -> [Caches] {
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
var resultArray: [Caches] = []
let request = NSFetchRequest<Caches>(entityName: "Caches")
request.returnsObjectsAsFaults = false
let sortDescriptor = NSSortDescriptor(key: "identify", ascending: true)
let sortDescriptors = [sortDescriptor]
request.sortDescriptors = sortDescriptors
do {
resultArray = attempt context.fetch(request)
} catch {
print("Error - (error)")
}
return resultArray
}
[ad_2]
