Embed (wrap) one code block into other structure

Hello guys,


is there a shortcut an easy way, how to wrap block of code (espacially while with SwiftUI) into another generic structure?


I found there is command+click quick action menu to Embed in HStack, VStack and List, which is very nice and convenient feature, but I'd like to have something same available when I want to put block of code inside other structure, like guard, if or if let condition, or when I need to put one view inside another, (all that happens quite often with SwiftUI).


I know probably to some of you might sound like stupid this question, but so far I could not find out, if there's such feature, I would love to know, have good day everyone, bye bye.


Manoli

If this is a SwiftUI question, you'd better move to SwiftUI section.


Not sure I understand your question nor your purpose, but, what about declaring a closure and reusing ?

That was just simple question related to Xcode editor, I don't know how to explain my question more clear...


...well if it is possible quickly with keyboard or mouse-click shortcut put block of code inside other structure like for example transform:


Text("Hello, World!")


into


something {
     Text("Hello, World!")
}


Thank you.

Hold down the cmd key-> hover over the View element you want to wrap (TextView, for example) -> Click on this View (while holding cmd) -> "Embed in VStack"

Embed (wrap) one code block into other structure
 
 
Q