#pragma mark - 1.存储本地数据
+(void)AddLocalDataWithInformation:(NSString*)data andKey:(NSString*)key;
#pragma mark - 2.删除本地数据
+(void)DeleteLocalDataWithInformation:(NSString*)data;
#pragma mark - 3.修改本地数据
+(void)ModifyTheLocalDataWithInformation:(NSString *)data andKey:(NSString*)key;
#pragma mark - 4.查找本地数据
+(NSString*)FindLocalDataWithInformation:(NSString*)data andKey:(NSString*)key;
#pragma mark - 1.存储本地数据
+(void)AddLocalDataWithInformation:(NSString*)data andKey:(NSString*)key
{
//删除数据
[[NSUserDefaults standardUserDefaults] removeObjectForKey:key];
///保存数据前先删除数据
[[NSUserDefaults standardUserDefaults] setObject:data forKey:key];
[[NSUserDefaults standardUserDefaults] synchronize];
}
#pragma mark - 2.删除本地数据
+(void)DeleteLocalDataWithInformation:(NSString*)data
{
[[NSUserDefaults standardUserDefaults]removeObjectForKey:data];
}
#pragma mark - 3.修改本地数据
+(void)ModifyTheLocalDataWithInformation:(NSString *)data andKey:(NSString*)key
{
// 不可修改本地不可变字典
NSDictionary * useInformationDic = [[NSUserDefaults standardUserDefaults] objectForKey:@"UserInformation"];
NSMutableDictionary * mutableDic = [[NSMutableDictionary alloc] initWithDictionary:useInformationDic];
[mutableDic removeObjectForKey:key];
[mutableDic setObject:data forKey:key];
NSDictionary * newUserInforDic = [mutableDic mutableCopy];
[[NSUserDefaults standardUserDefaults] setObject:newUserInforDic forKey:@"UserInformation"];
}
#pragma mark - 4.查找本地数据
+(NSString*)FindLocalDataWithInformation:(NSString*)data andKey:(NSString*)key
{
if (nil != [[[NSUserDefaults standardUserDefaults]objectForKey:data]objectForKey:key]) {
return [[[NSUserDefaults standardUserDefaults]objectForKey:data]objectForKey:key];
}
else
{
return @"";
}
}