var authRef: AuthorizationRef
var authFlags: AuthorizationFlags = AuthorizationCreate(rights:nil, environment:kAuthorizationEmptyEnvironment, flags:kAuthorizationFlagDefaults, authorization:&authRef)

错误
/AppDelegate.swift:26:89: 'kAuthorizationEmptyEnvironment' is unavailable: use 'nil' instead of this imported macro

错误
/AppDelegate.swift:26:45: Cannot convert the expression's type '$T6' to type 'AuthorizationFlags'

如何将这个objective-c代码转换成swift?
static AuthorizationRef authRef;
static AuthorizationFlags authFlags;
authFlags = kAuthorizationFlagDefaults
| kAuthorizationFlagExtendRights
| kAuthorizationFlagInteractionAllowed
| kAuthorizationFlagPreAuthorize;
OSStatus authErr = AuthorizationCreate(nil, kAuthorizationEmptyEnvironment, authFlags,&authRef);

Xcode项目文件
https://github.com/jaywcjlove/Proxy

最佳答案

第二个错误的原因是:AuthorizationCreate返回OSStatus。但是您将结果分配给authFlags这是另一种类型。

09-06 03:22