TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

How to compose complex views in SwiftUI

Forums > SwiftUI

I'm a bit lost. I see all kind of advantages in SwiftUI in designing views in which you use Text, TextField, Button and Image views and the like and I did some nice coding for ios. If you want to do programming for MacOs the documentation is suddenly very poor. I probably misjudge what swiftui can do for you, but subclassing views so you can code every part of your main view seems not possible, dynamically adding and removing subviews non-existing and I can not find the control you have over transitions in the way you had with segue-like mechanisms, where you could switch between views and windows and had the choice of what to do with source and destination. In my opinion SwiftUI is a great step forward for ios, but (maybe due to very poor documentation) I am struggling to make it work for more complex MacOs apps. Can someone enlighten me and point to relevant documentation (NOT IOS) so I can give SwiftUI the appreciation it probably deserves. Thanx

2      

subclassing views so you can code every part of your main view seems not possible

SwiftUI views are structs so you can't subclass them. In SwiftUI you build complex views by creating smaller views and combining the smaller views to create the complex view.

Your question title is about composing complex views, but the body of your question is mostly about using SwiftUI on Mac. A good chunk of iOS SwiftUI learning material also applies to Mac. Lists are the biggest area where an iOS SwiftUI tutorial would not apply on Mac.

If you want to make a complex Mac app, you are better off using AppKit instead of SwiftUI.

Regarding SwiftUI for Mac documentation, no one is going to be able to provide links here because this forum blocks most outside links. Paul Hudson has a Hacking with macOS book that covers Mac development with SwiftUI. I have a website, Swift Dev Journal. If you go to the main page of my site, you will find a section of Mac development articles. The first article in that section contains a list of resources for learning Mac development.

2      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.