Thanks for the reply
Double clicking on the brace did the trick for highlighting the code block, but I can seem to get the gutter thing working to collapse. I don't see any change when I hover the pointer in the gutter area. Does the gutter have to be turned on? If so, how?
Mark
Post
Replies
Boosts
Views
Activity
Thanks for the reply. Currently, I'm more interested in MacOS development than iPhone, but I'll check out your reference,
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.
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.
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).
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
Monterey 12.0.1. Unfortunately, that's the only Mac that I have (M1 Mini, 8GB Ram, 256 GB) that can run Xcode. My 2014 MacBook Air only has 4GB so I don't think it can run Xcode. It won't upgrade past Big Sur.
There's probably not enough disk space to set up a different volume, but I do have an external SSD I could use.
I like it as it gets rid of the optional. However, but that still requires that the property 'callback' in ModelDemo and the property 'modelDemo' need to be var's. If there was a way to do everything in the init(), they could be let's.
This worked for me. Thanks
Thanks
Thanks
Thanks, that worked for me.
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
Thanks for the reply, but I am concerned about minimizing CPU usage.
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.