Post

Replies

Boosts

Views

Activity

Binding a function from ObservableObject
my class contains a function, class UserModel: ObservableObject { func fetchUser(){ // code } } i call this class in a struct struct UserView: View { @StateObject var userModel = UserModel() @State var loading: Bool = false var body: some View { ButtonComponent(loading: $loading) } } I would like to access the class in ButtonComponent just like i did with the loading variable by binding it. The ButtonComponent is like this.. struct ButtonComponent: View { @Binding var loading: Bool var body: some View { Button(action: {loading.toggle()}){ Text("Submit Button") } } } Help on how to achieve this is appreciated
1
0
577
Jun ’22
App store downloads hang and stop on loading
hi, at first i thought it was an xcode issue, i was trying to update it from the app store and it hang on loading i tried to update another app and the same issue happens, how can i fix this
Replies
0
Boosts
0
Views
732
Activity
Jul ’22
Binding a function from ObservableObject
my class contains a function, class UserModel: ObservableObject { func fetchUser(){ // code } } i call this class in a struct struct UserView: View { @StateObject var userModel = UserModel() @State var loading: Bool = false var body: some View { ButtonComponent(loading: $loading) } } I would like to access the class in ButtonComponent just like i did with the loading variable by binding it. The ButtonComponent is like this.. struct ButtonComponent: View { @Binding var loading: Bool var body: some View { Button(action: {loading.toggle()}){ Text("Submit Button") } } } Help on how to achieve this is appreciated
Replies
1
Boosts
0
Views
577
Activity
Jun ’22