Post

Replies

Boosts

Views

Activity

Why Store
When developing my code, I have seen people saying I should create a Store (eg: ProductStore) with ObservableObject/Published and inside of it, create functions to call the API (eg: ProductAPI) What's the reason for that ? Thank you
2
0
535
Aug ’21
EnvironmentObject
Checking an existing code, I could see an environmentObject set in my main file. What does it mean ? it means I am creating an instance of my store and making them available for the entire application ? Like a static instance in other languages ? or there is something else ? Thank you, @main struct myApp: App { var myStore = MyStore() var body: some Scene { WindowGroup { ContentView() .environmentObject(myStore)
1
0
431
Aug ’21
Create Instance of class
When instanciating an array of ProductModel, I do this way and everything works fine: @Published var products = [ProductModel]() However If I just want one instance, I have an error: @Published var product = ProductModel() Missing argument for parameter 'from' in call Why is this problem happening ? Thx
2
0
516
Jun ’21
Break Line
When I use: Text("My text \nhas a break line") The output is: My text has a break line PERFECT - I have "My text" and in the next line, I have "has a break line" However if I have: Text(mymodel.description) //where this is returning from an API call and mymodel.description contains "My text \nhas a break line") It doesn't work. The output is: My text \nhas a break line Why ?
1
0
1.1k
Jun ’21
Why Store
When developing my code, I have seen people saying I should create a Store (eg: ProductStore) with ObservableObject/Published and inside of it, create functions to call the API (eg: ProductAPI) What's the reason for that ? Thank you
Replies
2
Boosts
0
Views
535
Activity
Aug ’21
EnvironmentObject
Checking an existing code, I could see an environmentObject set in my main file. What does it mean ? it means I am creating an instance of my store and making them available for the entire application ? Like a static instance in other languages ? or there is something else ? Thank you, @main struct myApp: App { var myStore = MyStore() var body: some Scene { WindowGroup { ContentView() .environmentObject(myStore)
Replies
1
Boosts
0
Views
431
Activity
Aug ’21
Create Instance of class
When instanciating an array of ProductModel, I do this way and everything works fine: @Published var products = [ProductModel]() However If I just want one instance, I have an error: @Published var product = ProductModel() Missing argument for parameter 'from' in call Why is this problem happening ? Thx
Replies
2
Boosts
0
Views
516
Activity
Jun ’21
Break Line
When I use: Text("My text \nhas a break line") The output is: My text has a break line PERFECT - I have "My text" and in the next line, I have "has a break line" However if I have: Text(mymodel.description) //where this is returning from an API call and mymodel.description contains "My text \nhas a break line") It doesn't work. The output is: My text \nhas a break line Why ?
Replies
1
Boosts
0
Views
1.1k
Activity
Jun ’21