Crashes when I retrieve data from DB.
public func retrieveData<T: NSManagedObject>(entityName: String) -> [T]? {
let fetchRequest = NSFetchRequest(entityName: entityName)
do {
let result = try context.fetch(fetchRequest)
if result.isEmpty {
return nil
} else {
return result
}
} catch {
return nil
}
}
Crash: Thread 35: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)