Post

Replies

Boosts

Views

Activity

Reply to How to import large data from Server and save it to Swift Data
Do you know how much data is expected to be downloaded? If so, you could ensure the view doesn't update until the right amount of data is received and stored. If you don't know the quantity of data, you could add a Bool and toggle it when the data loading starts, then toggle it when the data has finished loading, so the View is only refreshed when the last of the data is stored. Another way would be to disable the UI so the user can't interact with it until the data has finished loading. The UI would update in the background, but the user wouldn't experience a slow UI as they can't interact with it anyway. You could put a partially-transparent View with a ProgressView in it at the top of a ZStack (which would be at the bottom of the ZStack in the code...) and hide it when you're done. I'll show you how I do it below. There's a few ways of doing it, but I don't think there's a built-in way to achieve this. But then, I'm not a genius on SwiftData, so... Using a blocking view: @State private var loadingData: Bool = false var body: some View { ZStack { // ... UI goes here // ... BlockingView() .additional().hidden(loadingData) // Hide the view when loading data == true } } struct BlockingView: View { var body: some View { ZStack { Rectangle() .fill(Color.black.opacity(0.2)) // Partially-transparent, but doesn't have to be ProgressView(label: { Label(title: { Text("Please Wait") }, icon: { Image(systemName: "exclamationmark.circle") }) }) .frame(width: 240, height: 100) .background(.ultraThickMaterial) .clipShape(RoundedRectangle(cornerRadius: 24)) .shadow(color: .black.opacity(0.3), radius: 4, x: 0, y: 0) } .ignoresSafeArea() } } /* This modifier is required because you can't conditionally hide a view with `.hidden()` but on the plus side, you can use this in tons of places, and add new modifiers like conditional shadows etc. */ public struct Additional<Content> { public let content: Content public init(_ content: Content) { self.content = content } } extension View { var additional: Additional<Self> { Additional(self) } } extension Additional where Content: View { @ViewBuilder func hidden(_ hide: Bool) -> some View { if(hide) { content.hidden() } else { content } } }
Apr ’25
Reply to Shadow-banned by design: the App Store visibility crisis for independent developers
These are the Developer Forums, where developers of third-party apps for Apple's platforms ask each other for hints and tips on coding. These forums are not where Apple's actual employee developers chat about what they're doing in the platform code. If you have a suggestion, you should raise it at: https://www.apple.com/feedback/ or https://feedbackassistant.apple.com/ and post the FB number here.
Apr ’25
Reply to Request for Rosetta: support optionally faster x87 emulation (via some env variable similar to AVX) like Rosettax87 project..
These are the Developer Forums, where developers of third-party apps for Apple's platforms ask each other for hints and tips on coding. These forums are not where Apple's actual developers chat about new features. If you have a suggestion, you should raise it at: https://www.apple.com/feedback/ or https://feedbackassistant.apple.com/ and post the FB number here.
Topic: App & System Services SubTopic: Core OS Tags:
Apr ’25
Reply to Extra Trailing Closure for List {}
I even removed my code and copy-pasted Apple's sample from here If you had done that, you wouldn't have those extra indents in the code (before every Text). When I paste it I get this: struct ContentView: View { var body: some View { List { Text("A List Item") Text("A Second List Item") Text("A Third List Item") } } } So, as @Claude31 says, you may have one or more non-printing characters in there.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’25
Reply to iOS18, certificates, mail app and domain
Sorry, what is your question for us not-employed-by-Apple, third-party developers who write third-party software for Apple's platforms? If you're just having a moan, sorry, but this isn't the place for that. These are the Developer Forums, where developers of apps for Apple's platforms ask each other for hints and tips on coding. If you have a product support question I'd suggest you ask it over at the Apple Support Forums. If, however, you have a suggestion raise it at https://feedbackassistant.apple.com/ Thanks.
Topic: Community SubTopic: Apple Developers Tags:
Apr ’25
Reply to Xcode Build Failure
The error: The compiler is unable to type-check the expression in real-time generally means you're trying to do too many things in one place, and you should break it down a little. Firstly, to make it more readable, I'd put brackets around each ternary expression, for example: (row %2 == 0 ? Color.blue : Color.orange) so you can see which bits are enclosed. Then I'd split it out like this, creating a let for the various bits so they're individually evaluated prior to the larger expression. Also, I'd indent the code so it's more readable, putting the positive on the first line, and the negative on the next line, indented: let borderColor1 = (row %2 == 0 ? Color.blue : Color.orange) let borderColor2 = (shelterViewModel.getShelter(row: row, column: column).productId = ViewConstants.LAYOUT_DUMMY_ID ? Color.yellow : Color.green) .border( (shelterViewModel.getShelter0perationFormat() ? borderColor1 : (locationViewModel.getLocation(row: row, column: column) ? Color.red : borderColor2)), width: 0.5 //(self.interfaceLayout == ViewConstants.BACKEND_OPERATION ? 0.5 : 0.5) ) Finally, this bit at the end is pointless as the two values are the same: width: (self.interfaceLayout == ViewConstants.BACKEND_OPERATION ? 0.5 : 0.5) so you can replace it with 0.5, unless you're going to change one of those values?
Apr ’25
Reply to How do I use "views" and structures / what's wrong with my code?
We've already explained. A class contains variables and methods that act on those variables. For example, you might have a Ball class that contains x and y CGFloats for the position, and you'll have methods in the class that add/remove 1 to the values to move the ball's position, e.g.: class Ball { var x: CGFloat var y: CGFloat init(x: CGFloat, y: CGFloat) { self.x = x self.y = y } func moveRight() { x += 1 } func moveLeft() { x -= 1 } func moveUp() { y -= 1 } func moveDown() { y += 1 } } That's the class, all done. And to use it, you'd do this: let ball: Ball = Ball(x: 20, y: 50) redBall.moveDown() // redBall.y is now 51 redBall.moveLeft() // redBall.x is now 19 You've just posted code where lines 27, 29 and 31 create three instances of your Balls class inside the Balls class. That's not how it works. You should create those three instances of Balls outside of the class where you're going to use them. Then, despite @Claude31 giving you actual working code showing you where the 'struct Userview: View goes, you've ignored it completely, and put your UI code inside your Balls class. Then, you have a go at us for actually helping you and suggesting you don't use AI to learn coding. We are trying to help you, but if you don't take onboard any of our suggestions, why should we bother? I certainly aren't going to bother anymore.
Topic: UI Frameworks SubTopic: SwiftUI
Apr ’25
Reply to External Keyboard and Mouse Input Broken in iOS/iPadOS 18.4.1 — Apple and Third-Party Devices Affected (Magic Keyboard, Redragon K580RGBPRO, Razer Naga V2 Pro)
You should probably raise this as a bug in the usual way. It won't really get progressed if it's only posted in these Developer Forums. You need to raise each issue you find separately at https://feedbackassistant.apple.com/ You can post the FB numbers here if you want, so that others can link to them.
Topic: Community SubTopic: Apple Developers Tags:
Apr ’25
Reply to How do I use "views" and structures / what's wrong with my code?
There are so many things wrong with your code: You've created a class Balls, which should contain some variables and methods, but you've added a struct UserView inside. This struct should be outside of the class, at the same level as the class. Your #Preview should be at the root level, just like the class and the struct. for item in Balls is completely wrong for two reasons. Firstly, you're trying to access the class Balls not an instance of it, and secondly inside a View you have to use forEach, i.e. balls.forEach { item in. On line 57 you commented out //var balls [Int] = [ball1; ball2; ball3]. This syntax is wrong. You're missing a colon before the [Int] and you have to use commas not semicolons to separate items in an array, i.e. //var balls: [Int] = [ball1, ball2, ball3]. But, even then this is wrong because you're trying to create an array of Ints but you're passing in three objects which are of the type Balls. I think you need to go back to the beginning and look at how to write Swift and SwiftUI code. There are so many issues in your code here. I note, right at the top, on line 4, you've got a comment: Bouncing Balls Simulation without ChatGPT's Code. I fear you've attempted to use ChatGPT to write code for you. Please stop doing this. Learn how to write code properly. ChatGPT won't help you, and it has clearly led you down the wrong path. There are loads of resources to learn Swift. Apple provides tons of sample code that you can read, follow along with, and learn without resorting to unproven, dodgy 'AI'.
Topic: UI Frameworks SubTopic: SwiftUI
Apr ’25
Reply to Can't change iPhone watch app complication picker app name
Which versions of Xcode, iOS and watchOS are you using? There was a version of iOS where this happened, regardless of what you entered into those info.plist strings. Also, I highly recommend against using ChatGPT or any other AI tools for this sort of thing. They miss the nuances that a human will pick up in your questions, and - as you've experienced - they lead you down a bunch of rabbit holes that get you nowhere and just waste your time. You are far better off asking your questions to real humans in the forums.
Apr ’25
Reply to Mac App Crashing with Illegal Instructions
For some reason, people seem to think they need to make an entirely new thread to add a line of text or correct a spelling mistake... You have ONE HOUR from posting something to edit it. If you're outside that window, and the edit is necessary - your edit above really wasn't necessary - just reply to your own post. There is no reason to create duplicate posts within an hour. It just clutters up the forums.
Apr ’25