Questions tagged [swift-property-wrapper]
4 questions
7
votes
1 answer
Is there a way to access enclosing instance `ObservableObject` to call `objectWillChange.send()` from anywhere in a property wrapper
I'm trying to make a property wrapper similar to Combine's Published one(for my project needs), but with ability to modify the wrapped property by sending a value to a publisher, stored in projectedValue, like this:
// in class
@PublishedMutable var…

mrpaw69
- 155
- 9
1
vote
1 answer
SwiftUI - Is there a way to store a shape and then call it for .contentShape?
So I'm trying to set up a LOT of buttons that do the same thing when tapped, but have different content shapes. Some of these are custom shapes, some are rectangles, and all have modifiers. I wanted to set up a ForEach loop that would create a…

Juliana Nielson
- 19
- 1
0
votes
0 answers
updating @State variable in swiftUI not cause to reload when using delegate which called from outside
I have this code:
import SwiftUI
@main
struct MyWatchApp: App {
@State var myEnum: MyEnum = .first
var body: some Scene {
WindowGroup {
getCorrectView()
}
}
func getCorrectView() -> some View {
…

Mahdi Moqadasi
- 2,029
- 4
- 26
- 52
-3
votes
1 answer
Why is a @State property in SwiftUI not readable from outside?
I only wan't to read, not to change the value of a @State property of my SwiftUI view. In .onAppear the value will be changed but that change is not visible to the outside world. Why?
class MyController : UIHostingController {
…

Dominik
- 101
- 12