Dynamic registry modifiable at runtime?

How best should I built a registry that is essentially a key/value store where the keys are string and the values could be any SwiftUI View struct. I'd also like this to be modifiable at runtime. So if I wanted to add/remove/replace entries.

This is kinda off-topic for this forum, given that this is kinda SwiftUI-specific -- such a question is better suited for the Apple Developer Forums

However, the only way to accomplish this totally dynamically in SwiftUI is to wrap your Views in AnyView, which is discouraged as it doesn't allow for static optimizations that SwiftUI performs on your view hierarchy.

1 Like
Terms of Service

Privacy Policy

Cookie Policy