Post

Replies

Boosts

Views

Activity

Reply to VStack initialization without parentheses
The init is defined as: init( alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil, @ViewBuilder content: () -> Content ) So, you can also call struct ContentView: View { var body: some View { VStack(content: { Text("sth") }) } } The Stack { } where the content (closure) is outside the parameters list, is just a writing facility. You can do the same in other Swift functions: array.map() { closure } or array.map { closure}
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’24
Reply to When using index in a ForEach loop in SwiftUI, you might encounter an "index out of range" error.
So, when you try: ForEach(Array(viewModel.testValues.enumerated()), id:\.offset) { index, data in What is the index value that causes crash ? Could you also add a print and show what you get: .onAppear { print("index", index) // <<-- ADD THIS if !viewModel.isLoading, viewModel.testValues.count - 2 == index { viewModel.fetch() print("fetch. index", index, viewModel.testValues.count) // <<-- ADD THIS } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’24
Reply to Urgent: Help Needed with App Store Submission Issue
We recently encountered an issue What issue ???   As I'm not entirely familiar with app development/coding, I'm reaching out to seek help with this. The forum is the right place… But Help on what ? What is your question ?   We also want to know if the issue we're experiencing Which issue ? When you post a question, please provide detailed information if you want to get help.
Apr ’24
Reply to ForEach creates Views twice
That's an old problem, as reported here: https://developer.apple.com/forums/thread/718281 That's caused by ForEach effectively, as no error here: var body: some View { // ForEach(1...1, id: \.self) { i in subview(0) // } Some explanation here: it is due to the way SwiftUI performs init. https://www.reddit.com/r/SwiftUI/comments/166m0tn/double_initiation_in_foreach_loop/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’24
Reply to XCode 15 warnings
For sure, Xcode may be very verbose and some warnings are hard to solve (even impossible). But you can silence the warnings and just keep errors. In the Issues navigator click on x at the bottom on the Filter line Could you show the real and more complete code, so that we can understand these "hang pont" (???) messages
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’24