IOS之网络状态设和NSUserDefaults的synchronize
#pragma mark - check net status
int apiCheckNetStatus()
{
Reachability *reachNet = [Reachability reachabilityWithHostName:@"www.apple.com"];//www.newsmth.net
int retNetStatus = -1;
switch ([reachNet currentReachabilityStatus]) {
case NotReachable:
retNetStatus = -1;
break;
case ReachableViaWWAN:
retNetStatus = 0;
break;
case ReachableViaWiFi:
retNetStatus = 1;
break;
default:
break;
}
return retNetStatus;
}
-(void)load_setting
{
NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
attachment_images_size = [[defaults objectForKey:@"attachment_images_size"] intValue];
upphoto_size = [[defaults objectForKey:@"upphoto_size"] intValue];
brcmode = [[defaults objectForKey:@"brcmode"] intValue];
strUsr = [defaults objectForKey:@"username"];
strPwd = [defaults objectForKey:@"password"];
my_notify_number = [(NSString *)[defaults objectForKey:@"my_notify_number"] intValue];
my_dismiss_version = [defaults objectForKey:@"dismiss_version"];
font_size = [(NSString *)[defaults objectForKey:@"font_size"] intValue];
if(font_size < 8 || font_size > 32){
font_size = 16;
}
article_sort = [(NSString *)[defaults objectForKey:@"article_sort"] intValue];
order_threadid = [(NSString *)[defaults objectForKey:@"order_threadid"] intValue];
}
-(NSString *)getLoginInfoUsr
{
return strUsr;
}
-(NSString *)getLoginInfoPwd
{
return strPwd;
}
-(void)appSettingChange:(NSString *)name :(NSString *)value
{
NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];
[defaults setObject:value forKey:name];
[defaults synchronize];
[self load_setting];
}