Post

Replies

Boosts

Views

Activity

Reply to Bonjour TXT record vs Network framework
According to this post: https://stackoverflow.com/questions/76238555/why-are-txt-records-set-to-nil-when-using-nwbrowser-for-network-framework the problem is in the NWBrowser. There are two different descriptor types, .bonjour and .bonjourWithTXTRecord. Hopefully that will fix it. If not, you'll have to work your way through the debugging path.
Jul ’25
Reply to Accessing security scoped URLs without calling url.startAccessingSecurityScopedResource
[quote='post, Baylward, /thread/793561, /profile/Baylward'] This seems contrary to what the documentation says here [/quote] That documentation specifically refers to a security-scoped URL. That is a URL that you've retrieved from a security-scoped bookmark. If you've retrieved the URL from some other means, then these methods may not necessary (but see below). [quote='post, Baylward, /thread/793561, /profile/Baylward'] why not save and retrieve the URL immediately in order to avoid having to make any additional calls to url.startAccessingSecurityScopedResource?[/quote] Saving and retrieving a URL is a time-consuming hassle, especially compared to calling these two methods. You only want to do that if you really need to. You can call start/stopAccessingSecurityScopedResource on any URL. You just have to pay attention to the result from startAccessingSecurityScopedResource. You only need to call stop if start returned true. When you get a URL via the standard UI pickers, then it already has an implicit "start". That's why it works. There's no problem with calling "start" again, as long as you don't call "stop" if "start" returns false. This is handy for cases where you do the URL handling elsewhere. You can just always call start/stop, and if you do it correctly, it will always work. In some cases, especially on macOS, saving and loading bookmarks can be more tricky, so that's another reason to avoid it if you don't need to do that.
Topic: App & System Services SubTopic: Core OS Tags:
Jul ’25
Reply to FileManager.removeItem(atPath:) fails with "You don't have permission to access the file" error when trying to remove non-empty directory on NAS
It's more likely that Finder is calling a network-specific file operation for the SMB or AFP connection. You said you "could" work around the problem by manually doing a recursive delete. But does that mean that this actually works? Permissions can be complicated, especially on a Linux-based file server that the user could have configured in an unusual fashion.
Topic: App & System Services SubTopic: Core OS Tags:
Jul ’25
Reply to Can't post because "This post contains sensitive language"
Hello, I have been working on an audio module that plays a specific sound at regular intervals -- similar to a workout timer that alerts the user to switching exercises every few minutes. I'm configuring my audio session like this: let session = AVAudioSession.sharedlnstance() try session.setCategory( .playback, mode: default, options: [.interruptSpokenAudioAndMixWithOthers, duckOthers] ) self.engine.attach(self.player) self.engine.connect(self.player, to: self.engine.outputNode, format: self.audioFormat) try session. setActive(true) I schedule playback using a DispatchQueue (that's what scheduleAudio does): self.scheduleAudio(at: interval.start) { do { try audio.engine.start() audio.node.play() for kue in interval.cues { audio.node.scheduleBuffer(kue.buffer, at: AVAudioTime(hostTime: kue.hostTime)) } } catch { print (Audio activation failed: \(error)") } } This works perfectly in the foreground. But once the app goes into the background, the scheduled callback runs, yet the audio engine does not start, resulting in 'AVAudioSession.ErrorCode.cannotStartPlaying'. Interestingly, if the app is already playing audio before going to the background, the scheduled sounds continue to play as expected. I have added the required background audio mode to my Info plist file by including the key UlBackgroundModes with the value audio. Is there anything else I should configure? What is the best practice to play periodic audio cues when the app runs in the background? How do apps that do turn-by-turn navigation handle continuous audio playback in the background? Any advice or pointers would be greatly appreciated!
Jul ’25