I’m presently studying Swift and for an project we’ve got to create a easy software. I’m attempting to get the EditButton() for my grasp checklist. I’ve added the EditButton() to the navigation bar, nevertheless, once I click on it, the areas within the ForEach go into edit mode, however not the “Check” textual content, and the surroundings variable does not replace.
That is my present code I’m utilizing to check:
import Basis
import SwiftUI
struct LocationMasterListView: View {
@Atmosphere(.editMode) var editMode
@Atmosphere(.managedObjectContext) non-public var viewContext
@FetchRequest (sortDescriptors: [], animation: .default)
non-public var areas: FetchedResults<Location>
var physique: some View {
Checklist {
Textual content("Check")
//Verify for edit
if (editMode?.wrappedValue == .lively){
Textual content("is enhancing")
}
else{
Textual content("not enhancing")
}
ForEach(areas) {
location in
NavigationLink(vacation spot: LocationDetailView(location: location)){
HStack{
MasterImageView(location: location)
VStack(alignment: .main){
Textual content(location.locationName)
Textual content(location.locationSuburb)
.font(.footnote)
.foregroundColor(.grey)
}
}
}
}.onDelete(carry out: deleteLocation)
}.navigationTitle("Favorite Locations")
.navigationBarItems(main: EditButton(), trailing: Button("+"){
addLocation()
})
}
}
The situation checklist merchandise that’s created within the ForEach exhibits the delete button and that works fantastic, however not the check textual content, and the if assertion stays on “not enhancing”.