Group Group Group Group Group Group Group Group Group

Your Second iOS and SwiftUI App · Edit Mode | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5662524-your-second-ios-and-swiftui-app/lessons/15

Is there a way to navigate from a list row while in editing mode? The functionality I’m looking for is like Apple has in their Clock App on the iPhone where you edit the alarm by tapping on the alarm cell while in edit mode.
Thanks Mike

1 Like

As far as I’ve been able to figure out, there’s no way to do this, unless you want to leave off the ability to move rows. Apple’s alarms are sorted by time so don’t need to be manually reordered.

How’s it done if you don’t need to move the rows?

I was able to use @Environment (/.editMode) var editMode and then use the wrappedValue. If it’s .active then I’m in editMode so I can do two different actions (NavigationLinks) based on that Bool. However, when I’m in edit mode at runtime, tapping the row does nothing. It doesn’t trigger the NavigationLink. Only tapping on the row when it’s not in editMode will trigger a NavigationLink. Not sure if this is the correct approach or not.

2 Likes

@aoi Do you still have issues with this?

Yes, never did figure it out. Do you have ideas?

@jessycatterwaul Can you please help with this when you get a chance? Thank you - much appreciated! :]

I’m using Xcode 11.3 and I get this error:
Cannot invoke initializer for type ‘NewTaskView’ with an argument list of type ‘(taskStore: TaskStore)’

I have checked my code against yours and can’t figure out what I have done wrong.

Also once I added a new task, the form ceases to work

Upload your project and I’ll have a look!

I fixed the original problem but I still have the crash situation with an index out of range error. Unfortunately, new users can’t upload attachments.

ForEach( taskStore.tasks.indices ) { index in
          RowView(task: self.$taskStore.tasks[index])
        }

this line of code is throwing a Thread 1: Fatal error: index out of range

Never mind, I did a clean of the build folder and seems to be working now

1 Like

Nice job on working through it!