Post

Replies

Boosts

Views

Activity

Reply to Simulate run/ bike move
Effectively, that should move: https://sarunw.com/posts/how-to-simulate-location-in-xcode-and-simulator/ But you should try with freeway drive (move will be larger and hence more visible, depending on the map scale). If you want to build your own GPX file: https://developer.apple.com/forums/thread/766507
Apr ’25
Reply to Xcode Build Failure
May be because image is upside down 😉 When you post a message, make it easy to use: image in correct orientation complete code so that one can test, in text, not only screenshot full error message Seems it is a problem to type check shelterViewModel.getShelter (row: row, column: column).productId == ViewConstants.LAYOUT_DUMMY_ what is productId type ? How are ViewConstants defined ? What is .LAYOUT_DUMMY_ ? Which type ? If it is not exactly the same as productId, then the error. Note: tests as shelterViewModel.getShelterOperationFormat() != true may be written !shelterViewModel.getShelterOperationFormat()
Apr ’25
Reply to How do I use "views" and structures / what's wrong with my code?
what's wrong with my code? Sorry to say, nearly everything. There are so many errors everywhere. You should start studying Swift first. As DarkPaw said, AI (ChatGPT or other) does not replace plain intelligence. It seems you don't even understand your own code, isn't it ? There are even many typos in code: extra } Balls[].xPosition is wrong syntax. What do you mean here ? The problem for the error message (there are likely many other) is you call for item in Balls You have to use ForEach in a view. In addition, Balls is not an array, even less an instance of array. And View struct should be outside of the class. Otherwise, how do you plan to access it ? Here is a start to correct those many errors: class Balls: Identifiable { //var color: String var xPosition: Int var yPosition: Int var xVelocity: Int var yVelocity: Int var radius: Int var gravity: CGFloat var restitution: Int var other: Balls? init(xPosition: Int, yPosition: Int, xVelocity: Int, yVelocity: Int, radius: Int, gravity: CGFloat, restitution: Int) //ADD COLOR { //self.color = color self.xPosition = xPosition self.yPosition = yPosition self.xVelocity = xVelocity self.yVelocity = yVelocity self.radius = radius self.gravity = gravity self.restitution = restitution } } struct UserView: View { let ball1: Balls = Balls (xPosition: 100, yPosition: 100, xVelocity: 3, yVelocity: 0, radius: 3, gravity: 0.3, restitution: 1) let ball2: Balls = Balls (xPosition: 200, yPosition: 50, xVelocity: -2, yVelocity: 2, radius: 3, gravity: 0.3, restitution: 1) let ball3: Balls = Balls (xPosition: 300, yPosition: 150, xVelocity: 4, yVelocity: -3, radius: 3, gravity: 0.3, restitution: 1) var timer = Timer.publish(every: 0.01, on: .main, in: .common).autoconnect() @State var balls: [Balls] init() { balls = [ball1, ball2, ball3] } var body: some View { VStack { //Background color Color.gray.edgesIgnoringSafeArea(.all) //var balls [Int] = [ball1; ball2; ball3] // for item in Balls { ForEach($balls) { $ball in // You change ball later, so a binding here Circle() .fill(Color.black) .frame(width: 50, height: 50) .position(x: CGFloat($ball.xPosition.wrappedValue), y: CGFloat($ball.yPosition.wrappedValue)) // Wrappedvalue because ball is a binding .onReceive(timer) { _ in // Need on argument in the closure // self.yVelocity += self.gravity // self refers to View, not to a ball ball.yVelocity = ball.yVelocity + Int(ball.gravity) // One is Int, the other Float. Why ? That forbids += // ball.xPosition = CGPoint(ball.xPosition + ball.xVelocity) // That's not a CGPoint, needs 2 arguments ball.xPosition = ball.xPosition + ball.xVelocity ball .yPosition = ball.yPosition + ball.yVelocity if ball.yPosition >= 500 - 25 { ball.yPosition = 500 - 25 ball.yVelocity = -ball.yVelocity * ball.restitution } if ball.xPosition <= 25 { ball.xPosition = 25 ball.xVelocity = -ball.xVelocity } if ball.xPosition >= 375 { ball.xPosition = 375 ball.xVelocity = -ball.xVelocity // I suppose that's what you mean insted of ball.velocityX } /* errrors below you'll have to correct yourself let dx: int = other.xPosition - self.xPosition let dy: int = other.yPosition - self.yPosition let distance: int = sqrt (dx * dx + dy * dy) if distance < self.radius + other.radius { self.xVelocity = -self.xVelocity * self.restitution self.yVelocity = -self.yVelocity * self.restitution other.xVelocity = -other.xVelocity * self.restitution other.yVelocity = -other.yVelocity * self.restitution } */ } } } } }
Topic: UI Frameworks SubTopic: SwiftUI
Apr ’25
Reply to 4.3a then 3.2f
What a long post just to explain your app was rejected. BTW, what is section 3.2f you refer in your title ? I do not see it in the guidelines. PS: you have posted several times for the same issue and show that you have received a confirmation by reviewer of clause 4.3. And I don't think your financial "proposal" will help in anyway, will probably have inverse effect. So it is not really useful to repeat the same message again.
Apr ’25
Reply to App stops responding to touch; works normally otherwise
Looks like the issue is not specific to your app. https://www.reddit.com/r/iphone/comments/1gnssap/iphone_apps_occasionally_stop_responding_to_touch/?rdt=53523 Did you file a bug report ? PS: if you google search for "iphone apps not responding to touch", you'll get a lot of similar reports as well as some videos explaining how to solve. Don't know how useful they are though.
Apr ’25
Reply to Alert structure and playing sound
There is effectively a problem, no sound. I tested with to different calls: func playInputClick() { var filePath: String? filePath = Bundle.main.path(forResource: "ButtonTap", ofType: "wav") let fileURL = URL(fileURLWithPath: filePath!) var soundID:SystemSoundID = 0 AudioServicesCreateSystemSoundID(fileURL as CFURL, &soundID) AudioServicesPlaySystemSound(soundID) } func playSound() { let alertSoundPath = URL(fileURLWithPath: Bundle.main.path(forResource: "ButtonTap", ofType: "wav")!) // Bundle.main.url(forResource: "classicAlarm", withExtension: "mp3")! do { let audioPlayer = try AVAudioPlayer(contentsOf: alertSoundPath) audioPlayer.play() } catch { // appData.logger.debug("Error playing sound: \(alertSoundPath)") } }: playSound does not work, while playInputClick() does. So, I would change your playSound as follows: func playSound() { let alertSoundPath = Bundle.main.path(forResource: "classicAlarm", ofType: "mp3")! let alertSoundURL = URL(fileURLWithPath: alertSoundPath) var soundID:SystemSoundID = 0 AudioServicesCreateSystemSoundID(alertSoundURL as CFURL, &soundID) AudioServicesPlaySystemSound(soundID) } In my tests, func are outside ContentView. I moved playSound inside ContentView and got the runtime error (but some sound): Modifying state during view update, this will cause undefined behavior. So, please, show complete code so that we can reproduce (as well as the resources).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’25