requestAuthorization(to:completionHandler:)
Requests authorization to perform a privileged file operation.
Declaration
func requestAuthorization(to type: NSWorkspace.AuthorizationType, completionHandler: @escaping @Sendable (NSWorkspace.Authorization?, (any Error)?) -> Void)func requestAuthorization(to type: NSWorkspace.AuthorizationType) async throws -> NSWorkspace.AuthorizationParameters
- type:
The type of file operation to perform.
- completionHandler:
The completion handler to call when the authorization request is completed.
The completion handler takes two parameters:
- authorization
The authorization granted for this app. Use it when creating a new Filemanager with Init(authorization:).
- error
nilif the app is authorized; otherwise, a pointer to the authorization error.