mirror of
https://github.com/Mueller-Patrick/DHBW-Service-App.git
synced 2026-04-28 18:30:09 +00:00
:saprkles: Adding CoreData Helper Classes
- Also adding lecturer entity and relationship between event and lecturers. - Preparation for CoreData refactoring
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="17709" systemVersion="20D62" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="YES" userDefinedModelVersionIdentifier="">
|
||||
<entity name="RaPlaEvent" representedClassName="RaPlaEvent" syncable="YES" codeGenerationType="class">
|
||||
<entity name="Lecturer" representedClassName="Lecturer" syncable="YES">
|
||||
<attribute name="email" optional="YES" attributeType="String"/>
|
||||
<attribute name="name" optional="YES" attributeType="String"/>
|
||||
<relationship name="event" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="RaPlaEvent" inverseName="lecturers" inverseEntity="RaPlaEvent"/>
|
||||
</entity>
|
||||
<entity name="RaPlaEvent" representedClassName="RaPlaEvent" syncable="YES">
|
||||
<attribute name="category" optional="YES" attributeType="String"/>
|
||||
<attribute name="descr" optional="YES" attributeType="String"/>
|
||||
<attribute name="endDate" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
||||
@@ -9,14 +14,16 @@
|
||||
<attribute name="startDate" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
|
||||
<attribute name="summary" optional="YES" attributeType="String"/>
|
||||
<attribute name="uid" optional="YES" attributeType="String"/>
|
||||
<relationship name="lecturers" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Lecturer" inverseName="event" inverseEntity="Lecturer"/>
|
||||
</entity>
|
||||
<entity name="User" representedClassName="User" syncable="YES" codeGenerationType="class">
|
||||
<entity name="User" representedClassName="User" syncable="YES">
|
||||
<attribute name="course" optional="YES" attributeType="String"/>
|
||||
<attribute name="director" optional="YES" attributeType="String"/>
|
||||
<attribute name="name" optional="YES" attributeType="String"/>
|
||||
</entity>
|
||||
<elements>
|
||||
<element name="RaPlaEvent" positionX="-63" positionY="9" width="128" height="149"/>
|
||||
<element name="User" positionX="-63" positionY="-9" width="128" height="74"/>
|
||||
<element name="Lecturer" positionX="-351" positionY="99" width="128" height="74"/>
|
||||
<element name="RaPlaEvent" positionX="-271.3642578125" positionY="83.64776611328125" width="128" height="164"/>
|
||||
<element name="User" positionX="-428.6358032226562" positionY="2.067169189453125" width="128" height="74"/>
|
||||
</elements>
|
||||
</model>
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Lecturer+CoreDataClass.swift
|
||||
// DHBW-Service
|
||||
//
|
||||
// Created by Patrick Müller on 10.02.21.
|
||||
//
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
@objc(Lecturer)
|
||||
public class Lecturer: NSManagedObject {
|
||||
@nonobjc public class func getAll() -> [Lecturer] {
|
||||
let managedContext =
|
||||
PersistenceController.shared.context
|
||||
|
||||
do {
|
||||
return try managedContext.fetch(Lecturer.fetchRequest())
|
||||
} catch let error as NSError {
|
||||
print("Could not fetch. \(error), \(error.userInfo)")
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// Lecturer+CoreDataProperties.swift
|
||||
// DHBW-Service
|
||||
//
|
||||
// Created by Patrick Müller on 10.02.21.
|
||||
//
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
|
||||
extension Lecturer {
|
||||
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<Lecturer> {
|
||||
return NSFetchRequest<Lecturer>(entityName: "Lecturer")
|
||||
}
|
||||
|
||||
@NSManaged public var email: String?
|
||||
@NSManaged public var name: String?
|
||||
@NSManaged public var event: RaPlaEvent?
|
||||
|
||||
}
|
||||
|
||||
extension Lecturer : Identifiable {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// RaPlaEvent+CoreDataClass.swift
|
||||
// DHBW-Service
|
||||
//
|
||||
// Created by Patrick Müller on 10.02.21.
|
||||
//
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
@objc(RaPlaEvent)
|
||||
public class RaPlaEvent: NSManagedObject {
|
||||
@nonobjc public class func getAll() -> [RaPlaEvent] {
|
||||
let managedContext =
|
||||
PersistenceController.shared.context
|
||||
|
||||
do {
|
||||
return try managedContext.fetch(RaPlaEvent.fetchRequest())
|
||||
} catch let error as NSError {
|
||||
print("Could not fetch. \(error), \(error.userInfo)")
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// RaPlaEvent+CoreDataProperties.swift
|
||||
// DHBW-Service
|
||||
//
|
||||
// Created by Patrick Müller on 10.02.21.
|
||||
//
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
|
||||
extension RaPlaEvent {
|
||||
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<RaPlaEvent> {
|
||||
return NSFetchRequest<RaPlaEvent>(entityName: "RaPlaEvent")
|
||||
}
|
||||
|
||||
@NSManaged public var category: String?
|
||||
@NSManaged public var descr: String?
|
||||
@NSManaged public var endDate: Date?
|
||||
@NSManaged public var isHidden: Bool
|
||||
@NSManaged public var location: String?
|
||||
@NSManaged public var startDate: Date?
|
||||
@NSManaged public var summary: String?
|
||||
@NSManaged public var uid: String?
|
||||
@NSManaged public var lecturers: NSSet?
|
||||
|
||||
}
|
||||
|
||||
// MARK: Generated accessors for lecturers
|
||||
extension RaPlaEvent {
|
||||
|
||||
@objc(addLecturersObject:)
|
||||
@NSManaged public func addToLecturers(_ value: Lecturer)
|
||||
|
||||
@objc(removeLecturersObject:)
|
||||
@NSManaged public func removeFromLecturers(_ value: Lecturer)
|
||||
|
||||
@objc(addLecturers:)
|
||||
@NSManaged public func addToLecturers(_ values: NSSet)
|
||||
|
||||
@objc(removeLecturers:)
|
||||
@NSManaged public func removeFromLecturers(_ values: NSSet)
|
||||
|
||||
}
|
||||
|
||||
extension RaPlaEvent : Identifiable {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// User+CoreDataClass.swift
|
||||
// DHBW-Service
|
||||
//
|
||||
// Created by Patrick Müller on 10.02.21.
|
||||
//
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
@objc(User)
|
||||
public class User: NSManagedObject {
|
||||
@nonobjc public class func getAll() -> [User] {
|
||||
let managedContext =
|
||||
PersistenceController.shared.context
|
||||
|
||||
do {
|
||||
return try managedContext.fetch(User.fetchRequest())
|
||||
} catch let error as NSError {
|
||||
print("Could not fetch. \(error), \(error.userInfo)")
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// User+CoreDataProperties.swift
|
||||
// DHBW-Service
|
||||
//
|
||||
// Created by Patrick Müller on 10.02.21.
|
||||
//
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
|
||||
extension User {
|
||||
|
||||
@nonobjc public class func fetchRequest() -> NSFetchRequest<User> {
|
||||
return NSFetchRequest<User>(entityName: "User")
|
||||
}
|
||||
|
||||
@NSManaged public var course: String?
|
||||
@NSManaged public var director: String?
|
||||
@NSManaged public var name: String?
|
||||
|
||||
}
|
||||
|
||||
extension User : Identifiable {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user