SMJobBless有一个对话框提示,告诉用户它正在安装帮助工具并输入密码以继续。我想改变文字。
以下代码不是更改文本,而是将自定义文本放在开头,仍显示默认文本。我错过了什么或做错了什么?
// Creating auth item to bless helper tool and install framework
AuthorizationItem authItem = {kSMRightBlessPrivilegedHelper, 0, NULL, 0};
// Creating a set of authorization rights
AuthorizationRights authRights = {1, &authItem};
NSString *promptText = @"Customized Text. Privilege?\n\n";
AuthorizationItem dialogConfiguration[1] = { kAuthorizationEnvironmentPrompt, [promptText length], (char *) [promptText UTF8String], 0 };
AuthorizationEnvironment authorizationEnvironment = { 0 };
authorizationEnvironment.items = dialogConfiguration;
authorizationEnvironment.count = 1;
// Specifying authorization options for authorization
AuthorizationFlags flags = kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights;
// Open dialog and prompt user for password
OSStatus status = AuthorizationCreate(&authRights, &authorizationEnvironment, flags, authRef);`
答案 0 :(得分:1)
使用kAuthorizationRightExecute而不是kSMRightBlessPrivilegedHelper将获得一个只询问输入密码的短文本..并使用kAuthorizationEnvironmentPrompt作为环境可以在提示的开头添加其他文本..