Post

Replies

Boosts

Views

Activity

Comment on XCODE SwiftUI Preview
I'm sure my app is crashing. My question is not why the app is crashing - I know it is crashing because it can't communicate with the external device (I will eventually need to fix that). Is there a way to get the PreviewProvider to use a UI context other than the main app? Or, am I missing the point of Previewing? I realize I don't have a "live" preview, but I don't need one. I just want to see (and adjust) how the various parts of the views look as I adjust the layout and options.
Oct ’21
Comment on XCODE SwiftUI Preview
Thanks for the reply. I see your answer addressed my question, but in this case,I think there was something else wrong with the design of the application, but I don't know what, I'm still learning about observable objects and environment objects. When I restructured the app to clean up those, the problem went away.
Oct ’21
Comment on Xcode Simulator Rotate
Thanks for the reply. I understand that the simulator has no sensor to determine orientation, if I rotate the simulator ⌘ + left or right arrow key on the keyboard, the simulator rotates on the Mac screen, going from portrait to landscape. If I exit the simulator while it is in landscape mode, when I restart the simulator, it comes up on the screen with the screen in landscape mode (home button on the right or left), but the contents are displayed in portrait mode (i.e. sideways). If I use the keyboard to rotate the simulator back to portrait mode, it displays properly in portrait mode. If I then rotate to landscape mode, it displays properly in landscape mode, but if I exit the simulator and restart it again displays the device in landscape mode but the screen in portrait mode (sideways).
Nov ’21
Comment on Compile for different macOS versions
Thank you for your speedy reply, but I must still be missing something. I created a simple macOS app and modified the ContenView struct. ''' struct ContentView: View {          var text: String {         if #available(macOS 12, *) {             return "Hello, world! OSX12"         } else {             return "Hello, world! OSX11"         }     }          var body: some View {         Text(text)             .padding()     } } ''' But no matter how I set the macOS Deployment Target in the project or deployment target in the target, it always displays Hello, world OSX 12 when I run it. Thanks
Nov ’21
Comment on How does Swift's #if tag work?
Thanks for the link. One of the posts stated that Swift does not have a pre-processor. I had just assumed that #if was like #ifdef in C/C++ where the compiler never saw the code. One other thing. Many other IDE's allow you to display code that is #ifdef'ed out differently so you can tell which code will be compiled. It doesn't look like XCode does that with Swift's #if
Apr ’22
Comment on Are there application classes where UIKit is a better choice than SwiftUI?
I likely don't understand how SwiftUI works, but If I have several views (as separate structs) placed in a VStack in a superview and the data for one view forces it to change, SwiftUI will redraw that view, then it will redraw the superview. Won't redrawing the super view trigger rebuilding of all the sibling views? As for performance, I wrote an app that displays a map using MapKit and I notice that the map view seems to be constantly redrawing even when there are no changes. In some cases you can see the pin vibrating and the CPU usage was over 10% according to the Xcode monitor. A similar AppKit app copied from an online example showed no CPU usage once the map and pin are drawn.
Apr ’22