Skip to content

Instantly share code, notes, and snippets.

@yourtion
Last active June 12, 2016 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yourtion/9349476b151ffa035200af37cbeb1a3a to your computer and use it in GitHub Desktop.
Save yourtion/9349476b151ffa035200af37cbeb1a3a to your computer and use it in GitHub Desktop.
Is http enable
- (BOOL)needTransportSecurity {
#if TARGET_OS_IPHONE
if([[[UIDevice currentDevice] systemVersion] compare:@"9.0" options:NSNumericSearch] != NSOrderedAscending){
return YES;
}
#elif TARGET_OS_MAC
NSDictionary *systemVersionDictionary = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];
if([[systemVersionDictionary objectForKey:@"ProductVersion"] compare:@"10.11" options:NSNumericSearch] != NSOrderedAscending){
return YES;
}
#endif
return NO;
}
- (BOOL)isHTTPEnable {
if([self needTransportSecurity]){
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
return [[[infoDict objectForKey:@"NSAppTransportSecurity"] objectForKey:@"NSAllowsArbitraryLoads"] boolValue];
}
return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment