SwiftPrivilegedHelper icon indicating copy to clipboard operation
SwiftPrivilegedHelper copied to clipboard

Not an issue, a Swift 5 improvement

Open stklieme opened this issue 6 years ago • 0 comments

Thank you for sharing this amazing project. However I'd like to make a suggestion.

Even in Swift 4 it's recommended to prefer Data over NSData but in Swift 5 it became still more comfortable. You can replace the authorizationRef(fromExternalForm method with

 static func authorizationRef(fromExternalForm data: Data) throws -> AuthorizationRef? {

      // Create an AuthorizationExternalForm from it's data representation
      var authRef: AuthorizationRef?
      var authRefExtForm = data.withUnsafeBytes{ $0.load(as: AuthorizationExternalForm.self) }

      // Extract the AuthorizationRef from it's external form
      try executeAuthorizationFunction { AuthorizationCreateFromExternalForm(&authRefExtForm, &authRef) }
      return authRef
 }

stklieme avatar Jun 18 '19 16:06 stklieme