Post

Replies

Boosts

Views

Activity

Reply to How do deal with NavigationSplitView not saving selection on iPhone
If you have a content and a detail, the content probably is a list, which stores the selected value via the 'selection' parameter. That value goes into the detail view. On the Apple website is an example. @State private var categories: [String] = [] @State private var selectedCategory: String? List( categories, selection: $selectedCategory ) { category in NavigationLink(category.name, value: category) } .navigationTitle("Categories")
Topic: UI Frameworks SubTopic: SwiftUI Tags:
2d
Reply to make a button do something
A NavigationStack with NavigationLink is a good choice if you would like to navigate to a different view. But it depends on what exactly you would like to do. A NavigationSplitView could also be an option. Have you already prepared something that you can post here?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
2d
Reply to NavigationSplitView, endless loop detail<->content
Hi Pokpong, I was not notified about your response. I waited for the data to load, and then deleted it, but the error is still there. The error still occurs even if recipes.removeAll() remains in place. Apple responded after just one day, stating that they were unable to reproduce the issue using my project. They then asked me for a video demonstrating the error. After I sent the video, I heard nothing further from them.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
4d
Reply to Charts are broken with Xcode 27, Plotting multiple lines
My first attempt using the ID didn't work, and the data continued to be displayed incorrectly. I’m not entirely sure what went wrong, so I tried again today. With the unique ID, the data was displayed correctly. This can be achieved either by implementing the Identifiable protocol or by using the chart initializer that accepts both data and an ID. struct MonthlyHoursOfSunshine: Identifiable { var city: String var date: Date var hoursOfSunshine: Double var monthlyId: UUID = UUID() init(city: String, month: Int, hoursOfSunshine: Double) { let calendar = Calendar.autoupdatingCurrent self.city = city self.date = calendar.date(from: DateComponents(year: 2020, month: month))! self.hoursOfSunshine = hoursOfSunshine } var id: UUID { monthlyId } } However, as I mentioned earlier, the Apple example I initially used as a reference is now flawed; the data neither implements Identifiable nor uses the initializer that includes an ID. Christian
Topic: UI Frameworks SubTopic: SwiftUI Tags:
2w
Reply to Charts are broken with Xcode 27, Plotting multiple lines
Hi, as I already mentioned in my first post—including a link to the Apple website—the example is not my own code; it comes from Apple itself. The example worked prior to version 27, which is why I formatted my data in exactly that way; it ran without any issues until version 27. I have already structured my data differently, though I might adjust it again. For now, however, I am occupied with other SwiftUI bugs—for instance, NavigationSplitView, endless loop detail<->content Unfortunately, no one has responded to the post yet. I wanted to wait for a response before submitting a bug report, in case the procedure I’m following is incorrect. Christian
Topic: UI Frameworks SubTopic: SwiftUI Tags:
3w
Reply to AVSpeechSynthesizer pulls words out of thin air.
Hi Claude, thank you for your answer. I have incorporated your bug report into my example and updated my repository. I reported a bug that someone else had already found—more than ten years before me. So, I don't have much hope that anything will happen there in the near future. I’ve also documented a few other bugs on my GitHub. Christian
Topic: Media Technologies SubTopic: Audio Tags:
3w
Reply to NavigationSplitView without detail information
Hello Travis, thank you for your answer. I chose this approach because I wanted to minimize the effort involved in switching to NavigationSplitView. I had assumed that the content and detail views would be set automatically thanks to NavigationLink and navigationDestination. However, I haven't found any examples that follow the pattern I used. I was just wondering why the detail area is mandatory, even if it’s empty. I infer that my approach isn't quite right from the behavior I'm seeing. I had already implemented your placeholder suggestion, and it indicates that something is wrong: the placeholder only appears once. When I switch categories, the placeholder doesn't show up; instead, a warning triangle appears. I’ve watched the video several times and also downloaded and carefully examined the accompanying source code. I also noticed today that the link to "Bringing robust navigation structure to your SwiftUI app" has been changed, as the old link no longer works. The link points to .../swiftui/bringing_robust_navigation_structure_to_your_swiftui_app, but the correct link is .../swiftui/bringing-robust-navigation-structure-to-your-swiftui-app. Underscores were replaced with hyphens. I might just stick with the two-column solution. Christian
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’26
Reply to Charts are broken with Xcode 27, Plotting multiple lines
This works var dataMultiLine: [LocationData.Series] { LocationData.last30Days } struct MultiLineView: View { var body: some View { VStack { Chart { ForEach(dataMultiLine) { series in ForEach(series.sales, id: \.day) { element in LineMark( x: .value("Day", element.day, unit: .day), y: .value("Sales", element.sales) ) } .foregroundStyle(by: .value("City", series.city)) .symbol(by: .value("City", series.city)) .interpolationMethod(.catmullRom) } } } .padding() } } This doesn't work var dataContent: [MonthlyHoursOfSunshine] = [ MonthlyHoursOfSunshine(city: "Cupertino", month: 1, hoursOfSunshine: 196), MonthlyHoursOfSunshine(city: "Seattle", month: 1, hoursOfSunshine: 74), MonthlyHoursOfSunshine(city: "Seattle", month: 12, hoursOfSunshine: 62), MonthlyHoursOfSunshine(city: "Cupertino", month: 12, hoursOfSunshine: 199), ] struct ContentView: View { var body: some View { VStack { Chart(dataContent) { LineMark( x: .value("Month", $0.date), y: .value("Hours of Sunshine", $0.hoursOfSunshine) ) .foregroundStyle(by: .value("City", $0.city)) .symbol(by: .value("City", $0.city)) } } .padding() } } Christian
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’26
Reply to How do deal with NavigationSplitView not saving selection on iPhone
If you have a content and a detail, the content probably is a list, which stores the selected value via the 'selection' parameter. That value goes into the detail view. On the Apple website is an example. @State private var categories: [String] = [] @State private var selectedCategory: String? List( categories, selection: $selectedCategory ) { category in NavigationLink(category.name, value: category) } .navigationTitle("Categories")
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
2d
Reply to make a button do something
A NavigationStack with NavigationLink is a good choice if you would like to navigate to a different view. But it depends on what exactly you would like to do. A NavigationSplitView could also be an option. Have you already prepared something that you can post here?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
2d
Reply to NavigationSplitView, endless loop detail<->content
Hi Pokpong, I was not notified about your response. I waited for the data to load, and then deleted it, but the error is still there. The error still occurs even if recipes.removeAll() remains in place. Apple responded after just one day, stating that they were unable to reproduce the issue using my project. They then asked me for a video demonstrating the error. After I sent the video, I heard nothing further from them.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
4d
Reply to Charts are broken with Xcode 27, Plotting multiple lines
My first attempt using the ID didn't work, and the data continued to be displayed incorrectly. I’m not entirely sure what went wrong, so I tried again today. With the unique ID, the data was displayed correctly. This can be achieved either by implementing the Identifiable protocol or by using the chart initializer that accepts both data and an ID. struct MonthlyHoursOfSunshine: Identifiable { var city: String var date: Date var hoursOfSunshine: Double var monthlyId: UUID = UUID() init(city: String, month: Int, hoursOfSunshine: Double) { let calendar = Calendar.autoupdatingCurrent self.city = city self.date = calendar.date(from: DateComponents(year: 2020, month: month))! self.hoursOfSunshine = hoursOfSunshine } var id: UUID { monthlyId } } However, as I mentioned earlier, the Apple example I initially used as a reference is now flawed; the data neither implements Identifiable nor uses the initializer that includes an ID. Christian
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
2w
Reply to Charts are broken with Xcode 27, Plotting multiple lines
Hi, as I already mentioned in my first post—including a link to the Apple website—the example is not my own code; it comes from Apple itself. The example worked prior to version 27, which is why I formatted my data in exactly that way; it ran without any issues until version 27. I have already structured my data differently, though I might adjust it again. For now, however, I am occupied with other SwiftUI bugs—for instance, NavigationSplitView, endless loop detail<->content Unfortunately, no one has responded to the post yet. I wanted to wait for a response before submitting a bug report, in case the procedure I’m following is incorrect. Christian
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
3w
Reply to AVSpeechSynthesizer pulls words out of thin air.
Hi Claude, thank you for your answer. I have incorporated your bug report into my example and updated my repository. I reported a bug that someone else had already found—more than ten years before me. So, I don't have much hope that anything will happen there in the near future. I’ve also documented a few other bugs on my GitHub. Christian
Topic: Media Technologies SubTopic: Audio Tags:
Replies
Boosts
Views
Activity
3w
Reply to NavigationSplitView without detail information
Hello Travis, thank you for your answer. I chose this approach because I wanted to minimize the effort involved in switching to NavigationSplitView. I had assumed that the content and detail views would be set automatically thanks to NavigationLink and navigationDestination. However, I haven't found any examples that follow the pattern I used. I was just wondering why the detail area is mandatory, even if it’s empty. I infer that my approach isn't quite right from the behavior I'm seeing. I had already implemented your placeholder suggestion, and it indicates that something is wrong: the placeholder only appears once. When I switch categories, the placeholder doesn't show up; instead, a warning triangle appears. I’ve watched the video several times and also downloaded and carefully examined the accompanying source code. I also noticed today that the link to "Bringing robust navigation structure to your SwiftUI app" has been changed, as the old link no longer works. The link points to .../swiftui/bringing_robust_navigation_structure_to_your_swiftui_app, but the correct link is .../swiftui/bringing-robust-navigation-structure-to-your-swiftui-app. Underscores were replaced with hyphens. I might just stick with the two-column solution. Christian
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’26
Reply to Question: Task modifier with id called on initial
As is often the case, a boolean field helps. @State private var flagField1: Bool = false .task(id: field1) { if flagField1 == false { flagField1 = true return } print("task 1") } As previously mentioned, onChange has a parameter called initial. That is handled better there. Christian
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’26
Reply to Charts are broken with Xcode 27, Plotting multiple lines
This works var dataMultiLine: [LocationData.Series] { LocationData.last30Days } struct MultiLineView: View { var body: some View { VStack { Chart { ForEach(dataMultiLine) { series in ForEach(series.sales, id: \.day) { element in LineMark( x: .value("Day", element.day, unit: .day), y: .value("Sales", element.sales) ) } .foregroundStyle(by: .value("City", series.city)) .symbol(by: .value("City", series.city)) .interpolationMethod(.catmullRom) } } } .padding() } } This doesn't work var dataContent: [MonthlyHoursOfSunshine] = [ MonthlyHoursOfSunshine(city: "Cupertino", month: 1, hoursOfSunshine: 196), MonthlyHoursOfSunshine(city: "Seattle", month: 1, hoursOfSunshine: 74), MonthlyHoursOfSunshine(city: "Seattle", month: 12, hoursOfSunshine: 62), MonthlyHoursOfSunshine(city: "Cupertino", month: 12, hoursOfSunshine: 199), ] struct ContentView: View { var body: some View { VStack { Chart(dataContent) { LineMark( x: .value("Month", $0.date), y: .value("Hours of Sunshine", $0.hoursOfSunshine) ) .foregroundStyle(by: .value("City", $0.city)) .symbol(by: .value("City", $0.city)) } } .padding() } } Christian
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Sep ’26