mirror of
https://github.com/Mueller-Patrick/DHBW-Service-App.git
synced 2026-04-28 18:30:09 +00:00
♻️ Refactored CoreData access
This commit is contained in:
@@ -22,4 +22,23 @@ public class Lecturer: NSManagedObject {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
@nonobjc public class func getSpecified(sortDescriptors: [NSSortDescriptor] = [], searchPredicate: NSPredicate? = nil) -> [Lecturer]{
|
||||
let managedContext =
|
||||
PersistenceController.shared.context
|
||||
|
||||
let fetchRequest: NSFetchRequest = Lecturer.fetchRequest()
|
||||
|
||||
fetchRequest.sortDescriptors = sortDescriptors
|
||||
if(searchPredicate != nil) {
|
||||
fetchRequest.predicate = searchPredicate
|
||||
}
|
||||
|
||||
do {
|
||||
return try managedContext.fetch(fetchRequest)
|
||||
} catch let error as NSError {
|
||||
print("Could not fetch. \(error), \(error.userInfo)")
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,4 +22,23 @@ public class RaPlaEvent: NSManagedObject {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
@nonobjc public class func getSpecified(sortDescriptors: [NSSortDescriptor] = [], searchPredicate: NSPredicate? = nil) -> [RaPlaEvent]{
|
||||
let managedContext =
|
||||
PersistenceController.shared.context
|
||||
|
||||
let fetchRequest: NSFetchRequest = RaPlaEvent.fetchRequest()
|
||||
|
||||
fetchRequest.sortDescriptors = sortDescriptors
|
||||
if(searchPredicate != nil) {
|
||||
fetchRequest.predicate = searchPredicate
|
||||
}
|
||||
|
||||
do {
|
||||
return try managedContext.fetch(fetchRequest)
|
||||
} catch let error as NSError {
|
||||
print("Could not fetch. \(error), \(error.userInfo)")
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,4 +22,23 @@ public class User: NSManagedObject {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
@nonobjc public class func getSpecified(sortDescriptors: [NSSortDescriptor] = [], searchPredicate: NSPredicate? = nil) -> [User]{
|
||||
let managedContext =
|
||||
PersistenceController.shared.context
|
||||
|
||||
let fetchRequest: NSFetchRequest = User.fetchRequest()
|
||||
|
||||
fetchRequest.sortDescriptors = sortDescriptors
|
||||
if(searchPredicate != nil) {
|
||||
fetchRequest.predicate = searchPredicate
|
||||
}
|
||||
|
||||
do {
|
||||
return try managedContext.fetch(fetchRequest)
|
||||
} catch let error as NSError {
|
||||
print("Could not fetch. \(error), \(error.userInfo)")
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user