Have this at the top:
`struct EditSocialView: View {
@Environment(.managedObjectContext) var managedObjectContext
@Environment(.presentationMode) var presentationMode
var lodge: Lodge = getLodgeData()
//this gets the list from CD
@FetchRequest(
entity: CDLodge.entity(),
sortDescriptors: [
NSSortDescriptor(keyPath: \CDLodge.lodge, ascending: true),
],
predicate: NSPredicate(format: "lodgeid == 3")
) var cdlodges: FetchedResults
var body: some View {`
As you can see, I have the id hardcoded as 3
the actual id that I want to use comes from the getLodgeData() method at the top (lodge.id)
this function retrieves a json string from UserDefaults and converts it to an instance of Lodge.
There is a button on the page that deletes this entry from CoreData. I tried to add the FetchRequest there as I can then use predicate: NSPredicate(format: "lodgeid == (lodge.id)") but I get a segmentation error.
seem to be going around in circles where I can do what I need to do, just not where I need to do it for it to work.
thanks
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: