Post

Replies

Boosts

Views

Activity

Reply to Picker without NavigationView
Here what I've figured out: If a picker is inside a Form, it's going to be frozen and not selectable Form { Picker("Choose a number", selection: $selection) { ForEach(0 ..< data.count, id: \.self) { index in Text(data[index]) } } } If I wrap this form in a NavigationView, it's going to work perfectly. NavigationView { Form { Picker("Choose a number", selection: $selection) { ForEach(0 ..< data.count, id: \.self) { index in Text(data[index]) } } } However for my current design, I can't have a NavigationView on this View. Is there a solution for that ? Thx
Dec ’21
Reply to NavigationLInk
You're right. I am doing in init. But if I remove from init, how can I create the loop to create the navigation links in body? struct MyListView: View { var category: categoryModel   @ObservedObject var store = MyStore() init(category: CategoryModel) { self.category = category store.getItemsByCategoryId: category.id) }   var body: some View { List(store.categories.indices, id:\.self) { categoryIndex in             let category = store.categories[categoryIndex]             NavigationLink(destination:                 CategoryView(categoryId: category.id)             )             {                 CategoryRow(category: category)             }           } }
Sep ’21
Reply to Calling a View
I tried to do that, but somehow the MyViewB (actually it's a list view) is opened but not active. What I mean by that is the listview is loaded inside (Sheet/FullScreenCover) but you can't select anything on it.
Sep ’21
Reply to DateFormatter - String to Date
The problem is when I am inside my formatDate function, if I debug mousing over the dateString variable, I can see the value "3000-01-01T08:00:00-08:00". But when it reaches the line "let finalDate = dateFormatter.date(from: dateString)!", it returns me the error "Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value" The question is how it found nil, if when I mouse over the dateString variable, I can see the value in there ? func formatDate(dateString: String) -> Date { //first I dont know why my parameter gets here nil   let dateFormatter = ISO8601DateFormatter() //at the dateFormatter, doesnt matter the options I set, the return is always the same.   dateFormatter.formatOptions = [ .withFullDate,     .withFullTime,   ]   let finalDate = dateFormatter.date(from: dateString)!   return finalDate }
Sep ’21