ios - Value retrieval from KeychainItem -
i tried retrieving string keychainitem, stored below:
@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)];
when retrieved below:
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)];
i received following value nslog(@"%@",token);
<63346264 32636462 64653234 34313862 38633537 31326235 66653464 63303731>
how retreive string saved? doing wrong here?
try this:
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];
Comments
Post a Comment