Authored by 周蓉君

优化设备状态的钥匙链读写。Review by 硬币。

... ... @@ -399,16 +399,26 @@ static NSString * const kYohoBuyUsedDevice = @"com.yoho.buy.useddevice";
if (yohoinfoKVPairs == nil) {
yohoinfoKVPairs = [NSMutableDictionary dictionary];
}
[yohoinfoKVPairs setObject:@"Y" forKey:kYohoBuyUsedDevice];
[YH_KeychainStore save:kYohoSecretInfo data:yohoinfoKVPairs];
if (![yohoinfoKVPairs[kYohoBuyUsedDevice] isEqualToString:@"Y"]) {
[yohoinfoKVPairs setObject:@"Y" forKey:kYohoBuyUsedDevice];
[YH_KeychainStore save:kYohoSecretInfo data:yohoinfoKVPairs];
}
}
+ (BOOL) isNewDevice
{
static NSString * usedDevice = nil;
if ([usedDevice isEqualToString:@"Y"]) {
return NO;
}
NSMutableDictionary *yohoinfoKVPairs = (NSMutableDictionary *)[YH_KeychainStore load:kYohoSecretInfo];
if (yohoinfoKVPairs == nil || yohoinfoKVPairs[kYohoBuyUsedDevice] == nil) {
return YES;
} else {
usedDevice = yohoinfoKVPairs[kYohoBuyUsedDevice];
return NO;
}
}
... ...