Post

Replies

Boosts

Views

Activity

Reply to View as a Parameter / Variable in SwiftUI
I used krebera's example to solve the question I had. Wrap the view in Anyview by replacing CustomView with the view you want to use. So... struct Whatever { 		 var view: AnyView } let myWhatever = Whatever(view: AnyView(Text("Bruh, krebera is rad, thank you sooooo much!")))
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’21
Reply to App Transport Security has blocked a cleartext HTTP
I was getting the error: "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." I realized the compiler was complaining about a parameter I had specified on a URLComponents object. The URLComponents object's .scheme paramater was set as "http", so I changed it to "https" and voila error goes away. Maybe somewhere in your url object, there is an "http", and the compiler wants "https". Hope this helps. Also, make sure if you haven't already added the dictionary "App Transport Security Settings" to your main app targets info, inside this dictionary there should be a boolean value "Allows Arbitrary Loads", it's value should be set to "YES" This was done on XCode 13 beta 1
Jul ’21
Reply to How to solve "Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates." error?
I got the error to go away by changing the .onAppear modifier to .task on a SwiftUI view observing a published property. Below the navigation title modifier of the view. .navigationTitle("Where you're at") .task { // Fetch data from CloudKit here viewModel.fetchData() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’23