gpt4 book ai didi

ios - 从 KeychainItem 中检索值

转载 作者:行者123 更新时间:2023-11-28 22:07:08 24 4
gpt4 key购买 nike

我尝试从 KeyChainItem 中检索一个字符串,其存储如下:

@property (nonatomic, strong) KeychainItemWrapper *account;
if (account == nil) {
account = [[KeychainItemWrapper alloc] initWithIdentifier:@"test" accessGroup:nil]
}

[account setObject:self.username forKey:(__bridge id)(kSecAttrAccount)];
[account setObject:@"c6a07d48aabf35b26e1623fb" forKey:(__bridge id)(kSecValueData)];

当我检索到它时如下:

  KeychainItemWrapper *wrapper = [[KeychainItemWrapper alloc] initWithIdentifier:@"test" accessGroup:nil];
self.account = wrapper;
}

NSString *prevUsername = [account objectForKey:(__bridge id)(kSecAttrAccount)];
NSString *token = [account objectForKey:(__bridge id)(kSecValueData)];

我收到了 NSLog(@"%@",token) 的以下值;

<63346264 32636462 64653234 34313862 38633537 31326235 66653464 63303731>

如何取回我保存的字符串?我在这里做错了什么吗?

最佳答案

试试这个:

NSData *nameData= [account objectForKey:(__bridge id)(kSecAttrAccount)];
NSData *tokenData = [account objectForKey:(__bridge id)(kSecValueData)];

NSString *prevUsername = [[NSString alloc] initWithData:nameData encoding:NSUTF8StringEncoding];

NSString *token = [[NSString alloc] initWithData:tokenData encoding:NSUTF8StringEncoding];

关于ios - 从 KeychainItem 中检索值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23705986/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com