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