Skip to content

Instantly share code, notes, and snippets.

@yourtion
Last active Jun 12, 2016
Embed
What would you like to do?
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