In my app I need to have access to the users desktop, and I would like to implement the standard dialogue for the user to give permission for this access at launch. I do not want to use the NSOpenPanel() for the user to select the desktop, as I dont think that is an elegant solution.
However I am having issues implementing this.
I use the following code to be granted access to the Desktop URL:
let accessGranted = desktopURL.startAccessingSecurityScopedResource()
However no dialogue box appears and the call returns false
I have also included "Desktop Usage Description" in my plist.
Here is my code
@State var message:String = "Good Luck!"
var body: some View {
VStack {
Button("Get Desktop files") {
accessDesktopWithPermission()
}
Text(message)
}
.padding()
}
//: –—–—–—–—–—–—–—–—–—–—–—–—–—–— ://
func accessDesktopWithPermission(){
guard let desktopURL = getDesktopURL() else{
return
}
let accessGranted = desktopURL.startAccessingSecurityScopedResource()
if accessGranted{
if let content = try? FileManager.default.contentsOfDirectory(at: desktopURL, includingPropertiesForKeys: nil ){
message = "Found \(content.count) on Desktop"
}
else{
message = "issue loading file from desktop"
}
}
else{
message = "Access denied to:\(desktopURL )"
}
}
obviously I have setup something incorrectly so I have also attached my code if anyone is interested to take a look.
[https://www.openscreen.co/DesktopAccess.zip)
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi
Is there a way to check if a file at a specified URL is open and being edited by another application. Assuming that we have permission to access the file at the URL.
I have a Settings class that conform to the TestProtocol. From the function of the protocol I need to call the setString function and this function needs to be on the MainActor. Is there a way of make this work in Swift6, without making the protocol functions running on @MainActor
The calls are as follows:
class Settings: TestProtocol{
var value:String = ""
@MainActor func setString( _ string:String ){
value = string
}
func passString(string: String) {
Task{
await setString(string)
}
}
}
protocol TestProtocol{
func passString( string:String )
}
I just wanted to update my app, as it seems the in-app purchases were not updated in the first submission.
I created a new build and increased the version number by a minor increment, from 1 to 1.1, to ensure it gets processed. The build appears in TestFlight, but the plus button adjacent to the "Build" subsection does not appear, preventing me from selecting a new version. Please see the attached images.
VERY VERY FRUSTRATING
Lately I am getting this error.
GenerativeModelsAvailability.Parameters: Initialized with invalid language code: en-GB. Expected to receive two-letter ISO 639 code. e.g. 'zh' or 'en'. Falling back to: en
Does anyone know what this is and how it can be resolved. The error does not crash the app