按照我用来获取存储在自定义钥匙串中的密码的一段代码
-(OSStatus *)getPasswordFromKeyChain:(NSString *)username{
OSStatus status;
[self createKeyChainIfNotExists];
const char *cService_name = "Mac Google Analytics App";
UInt32 service_length = strlen(cService_name);
const char *cUser_name = [username cStringUsingEncoding:NSUTF8StringEncoding];
UInt32 username_length = strlen(cUser_name);
void *passwordData = nil;
SecKeychainItemRef itemRef = nil;
UInt32 passwordLength = nil;
status = SecKeychainFindGenericPassword(
mSecKeychainRef, // default keychain
service_length, // length of service name
cService_name, // service name
username_length,// length of account name
cUser_name, // account name
&passwordLength, // length of password
passwordData, // pointer to password data
NULL // the item reference
);
return status;
}
我想知道这段代码有什么问题,因为它永远不会来自这个调用:
SecKeychainFindGenericPassword
它指向此处显示的错误。