Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c Keychain请求多个帐户的权限_Objective C_Macos_Cocoa - Fatal编程技术网

Objective c Keychain请求多个帐户的权限

Objective c Keychain请求多个帐户的权限,objective-c,macos,cocoa,Objective C,Macos,Cocoa,在我的MacOS应用程序中,我存储了电子邮件帐户数据,因此在Keychain中保存了5个应用程序密码。当应用程序启动时,钥匙链要求5次始终允许。。。有没有办法让Keychain接受我的应用程序一次?例如,Adium存储多个帐户数据,其密钥链中只有一个条目:Internet密码 代码签名是避免这种情况的唯一方法吗 商店: } 得到 你会发布你用来在Keychain中存储项目的代码吗? +(void)storePasswordKeychainWithPassAndKey:(NSString *)pa

在我的MacOS应用程序中,我存储了电子邮件帐户数据,因此在Keychain中保存了5个应用程序密码。当应用程序启动时,钥匙链要求5次始终允许。。。有没有办法让Keychain接受我的应用程序一次?例如,Adium存储多个帐户数据,其密钥链中只有一个条目:Internet密码

代码签名是避免这种情况的唯一方法吗

商店:

}

得到


你会发布你用来在Keychain中存储项目的代码吗?
+(void)storePasswordKeychainWithPassAndKey:(NSString *)passwordStr:(NSString *)accountNameStr {
const char * accountName = [accountNameStr UTF8String];
const char * password = [passwordStr UTF8String];

OSStatus status;
status = SecKeychainAddGenericPassword(NULL, 
                                      strlen(serviceName), serviceName,
                                      strlen(accountName), accountName,
                                      strlen(password), password, 
                                      NULL);
+(NSString *) getPasswordKeychainWithKey: (NSString *)accountNameStr {
    const char * accountName = [accountNameStr UTF8String];
    void *password = nil;
    UInt32 passwordLen = 0;
    SecKeychainItemRef itemRef = nil;

    OSStatus status1;
    status1 = SecKeychainFindGenericPassword(NULL, 
                                             strlen(serviceName), serviceName,
                                             strlen(accountName), accountName,
                                             &passwordLen, &password,
                                             &itemRef);

    if (status1 == noErr) {
        NSData* passwordData = [NSData dataWithBytes:password length:passwordLen];
        SecKeychainItemFreeContent (NULL, password);
        return [NSString stringWithCString:[passwordData bytes] encoding:NSUTF8StringEncoding];
    }

    return nil;
}