Your Second iOS and SwiftUI App · Picker Views | 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/29

In the NewTaskView, after choosing a priority picker and adding a task text, get back to the ContentView and tap the Edit button. The delete selection button has gone and the moving row function cannot work.
Can you please explain this issue? How to fix it?

I’m still seeing the problem in the Xcode 11.2 beta. I doubt that it’s possible to explain the problem without the SwiftUI source code. :slightly_frowning_face: A workaround for the time being is to interact with the app in another way to “wake it up”, e.g. scrolling the list.

Hi Jessy,

I implemented the Picker without the Binding extension, this is probably just something Apple have resolved since you made the course. I did it but adding some functionality to the Task.Priority:

extension Task {
  enum Priority: CaseIterable, Identifiable {
    case no, low, medium, high
    
    var capitalizedStringValue: String {
      return "\(self)".capitalized
    }
    var id: Priority {self}
  }
}

Thank you for a great course, I look forward to the next one.

Paul

2 Likes

Hi Jessy,
I found a weird issue.
While selecting any task row(e.g. the high priority section), then getting back to the ContentView, there would be a warning message showned as below.
After continuely deleting every rows in the high priority section, then selecting any row in the other priority sections, the app will crash.
I am wondering if this is another bug in the swiftUI?

[TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window). This may cause bugs by forcing views inside the table view to load and perform layout without accurate information (e.g. table view bounds, trait collection, layout margins, safe area insets, etc), and will also cause unnecessary performance overhead due to extra layout passes. Make a symbolic breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch this in the debugger and see what caused this to occur, so you can avoid this action altogether if possible, or defer it until the table view has been added to a window.

1 Like

Thanks for sharing! I think the warning and the crash are possibly-related bugs. I sent them off to Apple a couple weeks ago and will update everyone in the Author Notes if I hear back.

Hi Jessy,
Thanks for your response and I am looking foreword to your updates.

I added this for the Picker for Xcode 11.2.1

Picker("Priority", selection: $taskPriority){
                ForEach(Task.Priority.allCases){ v in
                    Text(v.capitalizedStringValue).tag(v)
                }
            }
   .pickerStyle(SegmentedPickerStyle())

Maybe it will help the other to solve the issue in new Xcode version

@yuliagiarto Thank you for sharing your solution - much appreciated!

You’re using a capital A in AllCases, which is a type. You need allCases, which is the property of that type.

Hi after deleting the no priority tasks,I get a crash error.
Fatal error: Index out of range

2020-02-02 17:40:32.229488-0700 TaskList[28696:2048216] Fatal error: Index out of range

(lldb)

This happened end with the app I was building and the one I dowloaded from the course, will you make an update to fix this?

Sorry, still waiting on Apple from October 21 :frowning_face:: Your Second iOS and SwiftUI App · Conclusion | raywenderlich.com - #19 by rokk

1 Like

Hello Jessy
This was a great course. I just have a few questions.

How come it won’t let me add more than one task? It will let me add a task any time I delete an old one but i can’t add more than just one replacing the one I deleted.

Also I am running it on my iPhone and I would love to learn how to make the app keep the entries I’ve added after the app is closed and restarted. - not much of a question but if you could point me towards some resources that would be awesome -.

Thank you!

1 Like

Hey Jacob!

How come it won’t let me add more than one task?

This shouldn’t be the case. I’m wondering if you’re referring to the SwiftUI bug, where, at present, you can’t press the + button again, without doing something else in the UI first?

Also I am running it on my iPhone and I would love to learn how to make the app keep the entries I’ve added after the app is closed and restarted.

Fortunately, the upcoming Saving Data in iOS course will show you how to do exactly that!

Awesome!
Hopefully they fix these swiftUI bugs soon.

Thank you!

1 Like

Hi Jess,
I have an issue with the app. These are the steps:

1- Press + button and Go to NewTaskView
2- Enter name & priority and click Add button. Screen flow turns to ContenView and adds the new task in the right section.
3- Press again + button or Edit button. → Result: this two buttons does not function anymore. ==> To make them function again I have to refresh the screen or go to EditView screen and come back.

I thought I made a mistake while following you. So to be sure, I dowloaded your finished project and run it. Unfortunately, it also has same issue.

I am running project on the simulator(iPhone11).

Please could you check it and help me to solve this issue.

Thanks
Alex.