How to access a char* value store in cpp file and set Text ,using this value, in SwiftUI Text when a button is clicked?

I am trying to set Text value in my SwiftUI code from a char* string stored in cpp whenever a button is pressed .I was able to do similar think in UIkit based application and since i am new to SwiftUI not able to do same in SwiftUI.

SwiftUI code :

    @state var title = "Title"
 
    
    var body: some View {
        
        
            Text(title)
                .bold()
                .font(.system(size: 40))
                .frame(width: 250,height: 200,alignment: .center )
            Button("Change title", action: ChangeTitle)
            

    }

    
    func ChangeTitle () {
        //change value of title 
        
    }
    
}

Want to change the value of var title to char* str in cpp when button is pressed.

When dealing with model-level data like this:

  • A change can come from ‘above’, where the user makes a change in your view and you want to push that down into your model

  • Or from ‘below’, where something in your model triggers a change — perhaps you’re syncing some shared state over the network — and you want to reflect that in your view

Your description suggests that you only care about the first case. Is that correct?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How to access a char* value store in cpp file and set Text ,using this value, in SwiftUI Text when a button is clicked?
 
 
Q