In my Database class (all Swift) I have a function called selectFriends.
func selectFriends() -> [Friend] {
let delegate = UIApplication.shared.delegate as? AppDelegate
if let context = delegate?.persistentContainer.viewContext {
let request = NSFetchRequest<NSFetchRequestResult>(entityName: "Friend")
do {
return try context.fetch(request) as! [Friend]
} catch let error {
print(error)
return [Friend]()
}
}
else {
return [Friend]()
}
}
And when I assign the result to my variable
var friends: [Friend]
friends = database.selectFriends()
I get the error "Failed to call designated initializer on NSManagedObject ". The app works fine but the message appears in console.