Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    Working with @Generable and @Guide in Foundation Models

    July 18, 2025

    Navigating the labyrinth of forks

    July 18, 2025

    OpenAI unveils ‘ChatGPT agent’ that gives ChatGPT its own computer to autonomously use your email and web apps, download and create files for you

    July 18, 2025
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»ios – SwiftUI NavigationSplitView: Confused due to an official example by Apple
    iOS Development

    ios – SwiftUI NavigationSplitView: Confused due to an official example by Apple

    big tee tech hubBy big tee tech hubMarch 26, 2025012 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    ios – SwiftUI NavigationSplitView: Confused due to an official example by Apple
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    I’m tinkering with SwiftUI-NavigationSplitView. I started with this example from the official Developer-documentation.

    Overview

    The UI, I have made is very similar:

    import SwiftUI
    
    struct ContentView: View {
        @State var articles = [Article]()
        @State var selectedArticle: Article?
        
        var body: some View {
            NavigationSplitView {
                List(selection: $selectedArticle) {
                    ForEach(articles) { article in
                        // With attached .tag-modifier it works fine.
                        Text(article.name) // .tag(article)
                    }
                }
            } detail: {
                VStack(alignment: .leading) {
                    Text(selectedArticle?.name ?? "")
                        .font(.title2)
                        .bold()
                    Text(selectedArticle?.desc ?? "")
                    Spacer()
                }.padding()
            }
            .onChange(of: selectedArticle, {
                print(selectedArticle?.id)
                print(" ------------- ")
            })
            .onAppear() {
                for i in 1...6 {
                    let article = Article(
                        name: "Name_\(i)",
                        desc: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor.\nIn enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus."
                    )
                    articles.append(article)
                }
            }
        }
    }
    
    #Preview {
        ContentView()
    }
    

    Previously it hadn’t the .tag-modifier attached to the list-items.

    It didn’t work. The selectedArticle-variable never changed.

    Finally I found a forum-post, where I saw the usage of .tag. That remind me, how it could work.

    But I still don’t understand the example of Apple.

    How is it possible, that the Apple-example works? In case it really works.
    Can someone give some insights?

    Has it to do with the usage of IDs?



    Source link

    Apple Confused due iOS NavigationSplitView official SwiftUI
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    Working with @Generable and @Guide in Foundation Models

    July 18, 2025

    Deep dive into Swift frameworks

    July 17, 2025

    Apple News+ launches clever new ‘Emoji Game’ for iOS 18.4 and later

    July 17, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    Working with @Generable and @Guide in Foundation Models

    July 18, 2025

    Navigating the labyrinth of forks

    July 18, 2025

    OpenAI unveils ‘ChatGPT agent’ that gives ChatGPT its own computer to autonomously use your email and web apps, download and create files for you

    July 18, 2025

    Big milestone for the future of quantum computing.

    July 18, 2025
    Advertisement
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    Working with @Generable and @Guide in Foundation Models

    July 18, 2025

    Navigating the labyrinth of forks

    July 18, 2025

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2025 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.