Posts

Post not yet marked as solved
1 Replies
He's using the Swift Playgrounds app on the iPad. The app is also available on the Mac App Store, and should work similarly.
Post not yet marked as solved
9 Replies
Maybe this article will be more useful on NavigationView. It has an example near the begining that should get you started. The example is iOS, but (through the magic of declarative programming) the same code should work on MacOS.When there is a binding, you still need to pass the value in as an input when you create the view. One way you can do this is by creating a state in the parent view and accessing the Binding of the state (the variable name prefixed with $):struct HappyView: View { @State var someObject:SomeObject? var body: some View { ContentView(someObjects: [], selectedObject: $someObject) } }Overall, I would recomend watching the SwiftUI WWDC sessions, and going through the tutorial. Getting an understanding of the foundations is important before trying to dive into something (especially when it's as new as SwiftUI).Good luck!
Post marked as solved
3 Replies
This is listed as a known issue in the XCode release notes:"Xcode 11 beta 7 incorrectly reports as beta 6 on the welcome screen. (54795525)"
Post not yet marked as solved
1 Replies
If you are controlling the color with a State or something similar, all you need to do is make sure you change the state variable inside a withAnimation block.struct ColorView: View { @State var toggleable = true var body: some View { VStack { Text("Hello World") .background(Color(toggleable ? UIColor.blue : UIColor.red)) Button(action: { withAnimation { self.toggleable.toggle() } }) { Text("toggle") } } } }
Post not yet marked as solved
9 Replies
I believe that error usuall means that the parameters you passed into the function (in this case, List), does not match the signiture of the function.I got rid of the error by making SomeObject also conform to the Hashable protocol. This may be a decent ammount of work depending on what the "lots of other stuff" includes.struct SomeObject : Identifiable, Hashable { let id = UUID() let name: String // lots of other stuff } struct ContentView: View { var someObjects: [SomeObject] @Binding var selectedObject: SomeObject? var body: some View { List(someObjects, selection: $selectedObject) { item in Text(item.name) } } }edit: also, be sure to check out NavigationView to see if that does what you need. Based on your second comment, it sounds like that may be what you want.
Post not yet marked as solved
3 Replies
I noticed this too. It looks like this is listed as a known issue in the release notes."Xcode 11 beta 7 incorrectly reports as beta 6 on the welcome screen. (54795525)"
Post marked as solved
7 Replies
The truth is, someone answered the question on stackoverflow and not on these forums (also, notice the almost 2 months that passed with no responses). This is pretty common. The fact that the software is beta affects stackOverflow just as much as here.There are entire sections of this forum dedicated to beta software - it's just a ghost town.We can certainly attempt to do our part to improve these forums by answering questions when we can, but I fear it's futile.
Post not yet marked as solved
25 Replies
I was also seeing this issue in beta 6, and I am still seeing it in beta 7. Commenting out ObservedObject fixes the issue (but, of course, results in values not updating).You would think this would at least be listed as a known issue in the release notes!Has anyone filed a bug report? I will create one now!
Post not yet marked as solved
1 Replies
This works for me: Button(action: { print("hello") }) { Text("Hello") }I just had to remove the() -> PrimitiveButtonStyleConfiguration.Label inat the begining of the closure.
Post not yet marked as solved
4 Replies
I noticed that publisher sinks seem to unsubscribe when the cancellable gets destroyed - which is immediately if the cancellable is never assigned!This code is a start, but I think it may unsubscribe when it's containing scope is destroyed (eg. if it's in a function, when the function completes).let cancelable = publisher.sink{...}You may need to create the cancelable in a scope that will last longer in order for things to work as you expect.In a view such as the one in your code snippet, it will be difficult to create the cancelable that lasts because the view is a struct. In your case, you probably want to use onReceive.