mirror of
https://github.com/Mueller-Patrick/DHBW-Service-App.git
synced 2024-11-22 09:23:57 +00:00
🚧
This commit is contained in:
parent
2ea4182e63
commit
46551258e2
|
@ -6,9 +6,14 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import CoreData
|
||||||
|
|
||||||
struct HomeView: View {
|
struct HomeView: View {
|
||||||
@EnvironmentObject var settings: LocalSettings
|
@EnvironmentObject var settings: LocalSettings
|
||||||
|
@State var user: NSManagedObject = NSManagedObject()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
|
@ -18,6 +23,25 @@ struct HomeView: View {
|
||||||
Text("First opening toggle")
|
Text("First opening toggle")
|
||||||
}
|
}
|
||||||
Text("Test")
|
Text("Test")
|
||||||
|
|
||||||
|
// Text(user.value(forKey: "name") as! String)
|
||||||
|
|
||||||
|
}.onAppear{
|
||||||
|
self.readFromCoreData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension HomeView{
|
||||||
|
func readFromCoreData(){
|
||||||
|
let managedContext = PersistenceController.shared.context
|
||||||
|
let fetchRequest = NSFetchRequest<NSManagedObject>(entityName: "User")
|
||||||
|
|
||||||
|
do {
|
||||||
|
try print(managedContext.fetch(fetchRequest))
|
||||||
|
self.user = try managedContext.fetch(fetchRequest)[0]
|
||||||
|
} catch let error as NSError {
|
||||||
|
print(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user