SwiftUI / CoreData / Master / Detail (with editing) / Xcode 11 - Beta 5

前端 未结 3 1323
故里飘歌
故里飘歌 2020-12-14 13:08

Working on a sample app. The goal is to have a list pulled up from CoreData in a Master, and then click on one to go to a detail, where you can edit the information and sav

相关标签:
3条回答
  • 2020-12-14 13:50

    As promised, here is a link to sample SwiftUI program that uses CoreData. The current version compiles and runs on the GM release. It does not use the new @FetchRequest property wrapper because it does not suit all of my needs. I wrote a CoreDataDataSource class that does basically the same thing plus a lot more.

    https://github.com/Whiffer/SwiftUI-Core-Data-Test

    0 讨论(0)
  • 2020-12-14 14:03

    As @trapper explained, the entityName has to be bound the the MasterView.

    Updates are reflected when you add @ObservedObject in the DetailView as follows:

    @ObservedObject var entityName:EntityName
    
    0 讨论(0)
  • 2020-12-14 14:04

    You need to bind the entity in DetailView to the entity passed in from MasterView. Declare it like @Binding var entityName: EntityName

    0 讨论(0)
提交回复
热议问题