Post

Replies

Boosts

Views

Activity

How to go back to a prior version of Xcode? Version 13.4.1 won't work with iPhone iOS 15.6
So I've found out from other posts that Xcode 13.4.1 won't debug apps on iPhones with iOS 15.6. The solution everyone that everyone seems to agree on is to go back to Xcode 13.3.1. While I am downloading the xip file for that version, I want to check first on how to install the older version? I don't need to mess things up any worse than they are now.
2
0
1.9k
Aug ’22
How can I open an audio file into a buffer that I can read pieces of said buffer?
I would like to open an audio file on my iOS device and remove long silences. I already have the code for calculating volumes so am not pasting that here. What I am unsure of "how to do" is: While I believe that I have the proper code to read the file below, I am unsure as to how to read it in proper pieces to I can later get the volume of each piece. I realize that this might be a situation of calculating the size of frames and whatnot. But I am totally green when it comes to audio. I would seriously appreciate any guidance. guard let input = try? AVAudioFile(forReading: url) else { return nil } guard let buffer = AVAudioPCMBuffer(pcmFormat: input.processingFormat, frameCapacity: AVAudioFrameCount(input.length)) else { return nil } do { try input.read(into: buffer) } catch { return nil }
2
0
918
Dec ’22
Is there a global Alert View in SwiftUI?
I am writing a SwiftUI based app, and errors can occur anywhere. I've got a function that logs the error. But it would be nice to be able to call an Alert Msg, no matter where I am, then gracefully exits the app. Sure I can right the alert into every view, but that seems ridiculously unnecessary. Am I missing something?
2
0
114
Apr ’25
How can I execute animations for multiple SKSprintNodes at once?
I already know how to run multiple animations on the same SKSpriteNode at once: createPaths() let myIcon1 = MyIcon(wIcon: "screen", iSize: iSize) let move = SKAction.follow(iconPath[0], asOffset: false, orientToPath: false, duration: 1) let shrink = SKAction.resize(byWidth: -iSize.width/2, height: -iSize.width/2, duration: 1) let blur = SKAction.fadeAlpha(to: 0.6, duration: 1) let group = SKAction.group([shrink, move, blur]) myIcon1.run(group) But I have two more icons I would like to animate at the same time. Granted, with just 3 icons total I can't see any lag if I do something like this: myIcon1.run(group1) myIcon2.run(group2) myIcon3.run(group3) But surely there is a proper way to do this?
1
0
577
Feb ’21
Is there a way to translate touches to screen coordinates
As you can see in the last two lines of the code below, I specify a specific SKSpriteNode to get the correct (or is it, adjusted?) touch coordinates. The last line is just left in there to compare while I am debugging. I was curious if there was already a method in Swift that translates any coordinates handed to it into physical screen coordinates? It would just be easier than having to first find out: Is this item that I am tracking, owned by the main GameScene, or a SKSpriteNode that has been placed somewhere other than 0,0 on the GameScene? override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {         super.touchesEnded(touches , with:event)         var delta = CGPoint(x: 0, y: 0)         guard touches.first != nil else { return }         if let touch = touches.first,            let node = myGV.currentGem,            node.isMoving == true {             let touchLocation = touch.location(in: myGV.guessBar!)             let touchLocation2 = touch.location(in: self)
1
0
820
Jun ’21
How can I return a nil in Swift
I have a subclass of SKSpriteNode called MyGem. There are multiple instances of this class at runtime. They are all in an array of MyGems. At a specific point I would like to find out which MyGem is twinkling. The problem I am running into is if no MyGem is twinkling. What do I return? I can't return a nil. 'nil' is incompatible with return type 'MyGem' So what do I return? I thought of returning the index number of the MyGem in the array class, and then passing -1 if none were twinkling. But that seems kludgy. func getHighGem() -> MyGem {    for gem in myGems {     if gem.twinkling == true {     return gem       }    }     return nil //this line causes the IDE error }
1
0
3.7k
Jun ’21
Can I get an subclass's property from a function call that returns said subclass?
While debugging I would like to get a specific subclass's property. So far I can do this: if let myPeg = getTargetSlot(node: node, location touchLocation){           print (myPeg.index)             } Is it possible to write it in one line? Something like this? print ("\(getTargetSlot(node: node, location touchLocation).index") Because if there is a way, I cannot figure out the syntax. Thanks
1
0
442
Aug ’21
Why am I getting touchesCanceled instead of touchesEnded?
I am using debug labels so I know when I get any touchesBegan, touchesMoving, touchesEnded, and touchesCanceled. I get everything I expect, touchesBegan, touchesMoved, and touchesEnded. However, it would appear that if I barely, just barely move an SKSPriteNode, I get a touchesCanceled instead of touchesEnded. Even thought the call right before is touchesMoved. Is this as intended? Is there some threshold you have to reach to get an ended instead of a canceled? And if so, can I see and change it? Thanks More than glad to put my code, tho not sure how that would change anything.
1
0
672
Aug ’21