0

I am trying to use SSKeychain in my application to store a user's credentials. I can successfully save the credentails. However, when I try to retrieve the credentials, they are outputted as an NSArray. I want one specific value so I am using valueForKey:NSString which gives me ( acct )

Here is the code I am using

NSArray *accounts = [SSKeychain accountsForService:@"testApp"];
NSString *account = [accounts valueForKey:@"acct"];
NSLog(@"%@", account);

I would like for the output to be acct not (acct).

Krish
  • 3
  • 4

2 Answers2

0

accountsForService: returns an array of dictionaries, not an array of strings. See the docs: http://cocoadocs.org/docsets/SSKeychain/1.2.2/Classes/SSKeychain.html#//api/name/accountsForService:

You can find the keys you should use to retrieve info from the dictionaries in SSKeyChain.h

Joe
  • 111
  • 11
driis
  • 161,458
  • 45
  • 265
  • 341
0

Try this:

 NSArray *accounts = [SSKeychain accountsForService:@"testApp"];
 NSString *account = [[accounts valueForKey:@"acct"] objectAtIndex:0];

 NSLog(@"%@", account);
rckehoe
  • 1,198
  • 15
  • 16