Customize message for NSWorkSpace.requestAuthorization?

I'm using NSWorkSpace.requestAuthorization to remove some files. Can I customise the dialog? For my uninstaller the message "wants to save a file" is a bit odd:

AFAIK there’s no way to custom these alert.

I'm using NSWorkSpace.requestAuthorization(…) to remove some files.

I don’t understand this. When you call this method you supply a NSWorkspaceAuthorizationType value, and there’s no ‘remove file’ option.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Of course, you are correct. I'm using Xojo and the code is a bit different. I have a class to remove files. It gets the authorisation and the uses Filemanager with authorisation to delete some files:

Private Property theFileManager As NSFileManagerMBS
Public Sub Constructor(hasAppName as String, hasAuthorization as NSWorkspaceAuthorizationMBS, doRegistration as Boolean)
  
  AppName = hasAppName
  myAuthorisation = hasAuthorization
  theFileManager = NSFileManagerMBS.fileManagerWithAuthorization(myAuthorisation)
  
  DeleteApp
  
  if doRegistration then removeRegistration
  
End Sub

And Delete App:

AppFolder = SpecialFolder.Applications
if AppFolder <> nil and AppFolder.Exists then AppFolder = AppFolder.Child(AppCommon.getInstallationAppName)
if AppFolder = Nil or not AppFolder.Exists or not AppFolder.Directory then Return

dim theError as NSErrorMBS
dim theResult as Boolean = theFileManager.removeItem(AppFolder, theError)

I’m surprised this works. The doc comments <AppKit/NSWorkspace.h> say:

 Only the following NSFileManager methods currently take advantage of an authorization:
 
 -createSymbolicLinkAtURL:withDestinationURL:error:  (NSWorkspaceAuthorizationTypeCreateSymbolicLink)
 -setAttributes:ofItemAtPath:error:  (NSWorkspaceAuthorizationTypeSetAttributes)
 -replaceItemAtURL:withItemAtURL:backupItemName:options:resultingItemURL:error:  (NSWorkspaceAuthorizationTypeReplaceFile)

and AFAIK this is still accurate.

I suspect that you’re not actually getting any privilege escalation here. If you call -removeItemAtURL:error: on a standard instance of NSFileManager, does it work?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Customize message for NSWorkSpace.requestAuthorization?
 
 
Q