Dictionary write:
if ([self.currentuseraccount length] > 0) {
Keychainitemwrapper *keychainitem = [[Keychainitemwrapper alloc]initwithidentifier:@ "UserAccount" accessGroup:nil];
if (Keychainitem) {
if ([[Keychainitem objectforkey:ksecattraccount] length] > 0) {
already has data
Nsmutablearray *accountarray = [[Keychainitem objectforkey:ksecattraccount] propertylist];
if (Accountarray && [Accountarray Iskindofclass:[nsmutablearray class]] && [accountarray count] > 0)
{
Just store the different user account
Nsuinteger indexoftheobject = [Accountarray indexOfObject:self.currentUserAccount];
if (Indexoftheobject > [Accountarray count]) {
[Accountarray AddObject:self.currentUserAccount];
[Keychainitem setobject:[accountarray description] Forkey: (ID) ksecattraccount];
//}
for (int index = 0; index < [Accountarray count]; index + +) {
NSLog (@ "The value is%@", [Accountarray Objectatindex:index]);
}
}
}else{
Has no data
Nsmutablearray *accountarray = [Nsmutablearray arrayWithObject:self.currentUserAccount];
[Keychainitem setobject:[accountarray description] Forkey: (ID) ksecattraccount];
}
}
}
Dictionary read:
Keychainitemwrapper *tokenkeychainitem = [[[Keychainitemwrapper alloc]initwithidentifier:@ ' UserAuthToken ' Accessgroup:nil]autorelease];
if (Tokenkeychainitem && [[Tokenkeychainitem objectforkey:ksecvaluedata] length] > 0) {
[Tokenkeychainitem Resetkeychainitem];
Nsmutabledictionary *dictionary = [[Tokenkeychainitem objectforkey:ksecvaluedata] propertylist];
if (dictionary && [dictionary iskindofclass:[nsmutabledictionary class]] && [dictionary count] > 0) {
Self.tokenvalue = [Dictionary valueforkey:@ "token"];
Push the View
selectchildviewcontroller* Pushview = [[Selectchildviewcontroller alloc]init];
[Pushview SetTokenValue:self.tokenValue];
[Self.navigationcontroller Pushviewcontroller:pushview Animated:yes];
[Pushview release];
}
((kidsappdelegate*) [[[UIApplication Sharedapplication]delegate]]. Logintoken = Self.tokenvalue;
[Tokenkeychainitem Resetkeychainitem];
Has token
/*loginmanager *tmp = [[Loginmanager alloc]initwithusername:@ "" withpassword:@ "" withToken:self.tokenValue];
Self.login = tmp;
[TMP release];
[Self.login dologin];*/
}
Array write:
if ([self.currentuseraccount length] > 0) {
Keychainitemwrapper *keychainitem = [[Keychainitemwrapper alloc]initwithidentifier:@ "UserAccount" accessGroup:nil];
if (Keychainitem) {
if ([[Keychainitem objectforkey:ksecattraccount] length] > 0) {
already has data
Nsmutablearray *accountarray = [[Keychainitem objectforkey:ksecattraccount] propertylist];
if (Accountarray && [Accountarray Iskindofclass:[nsmutablearray class]] && [accountarray count] > 0)
{
Just store the different user account
Nsuinteger indexoftheobject = [Accountarray indexOfObject:self.currentUserAccount];
if (Indexoftheobject > [Accountarray count]) {
[Accountarray AddObject:self.currentUserAccount];
[Keychainitem setobject:[accountarray description] Forkey: (ID) ksecattraccount];
//}
for (int index = 0; index < [Accountarray count]; index + +) {
NSLog (@ "The value is%@", [Accountarray Objectatindex:index]);
}
}
}else{
Has no data
Nsmutablearray *accountarray = [Nsmutablearray arrayWithObject:self.currentUserAccount];
[Keychainitem setobject:[accountarray description] Forkey: (ID) ksecattraccount];
}
}
}
Array reads:
Keychainitemwrapper *keychainitem = [[Keychainitemwrapper alloc]initwithidentifier:@ "UserAccount" accessGroup:nil];
Self.accountarray = [Nsmutablearray array];
Self.lasttimeaccount = @ "";
if (Keychainitem) {
[Keychainitem Resetkeychainitem];
First get the old token if found delete//ksecvaluedata
if ([[Keychainitem objectforkey:ksecattraccount] length] > 0) {
Nsmutablearray *orignalarray = [[Keychainitem objectforkey:ksecattraccount] propertylist];
if (Orignalarray && [Orignalarray Iskindofclass:[nsmutablearray class]] && [orignalarray count] > 0)
{
Move the repeated item
Nsinteger index = [Orignalarray count]-1;
For (ID object in [orignalarray Reverseobjectenumerator]) {
if ([Orignalarray indexofobject:object inrange:nsmakerange (0, index)]! = Nsnotfound) {
[Orignalarray Removeobjectatindex:index];
}
index--;
}
}
Self.accountarray = Orignalarray;
if ([Self.accountarray count] > 0) {
Self.lasttimeaccount = [Self.accountarray objectatindex:[self.accountarray count]-1];
Self.switchBtn.hidden = NO;
}
}
[Keychainitem release];
}
iOS using Keychain specific methods