Ios 错误域=nsurErrorDomain代码=-1022 IIS服务器
我想用我的URL“http”不“https”在Xcode 7-iOS 9中发送(发布)一个文本数据。但我有一个错误: 错误域=NSURLErrorDomain代码=-1022“无法访问资源 已加载,因为应用程序传输安全策略要求使用 安全连接。“UserInfo={NSUnderlyingError=0x7f963a7c8690{Error 域=KCFerrorDomainCFN网络代码=-1022“(空)”}, NSErrorFailingURLStringKey=, NSErrorFailingURLKey=, NSLocalizedDescription=无法加载资源,因为 应用程序传输安全策略要求使用安全的 连接。} 我已经配置了我的info.plistIos 错误域=nsurErrorDomain代码=-1022 IIS服务器,ios,objective-c,json,Ios,Objective C,Json,我想用我的URL“http”不“https”在Xcode 7-iOS 9中发送(发布)一个文本数据。但我有一个错误: 错误域=NSURLErrorDomain代码=-1022“无法访问资源 已加载,因为应用程序传输安全策略要求使用 安全连接。“UserInfo={NSUnderlyingError=0x7f963a7c8690{Error 域=KCFerrorDomainCFN网络代码=-1022“(空)”}, NSErrorFailingURLStringKey=, NSErrorFailin
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
这在iOS 8中起作用,我尝试在POSTMAN(谷歌Chrome的应用程序)中使用URL,效果很好
怎么了?
谢谢
NSURL *WcfSeviceURL = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:WcfSeviceURL];
[request setHTTPMethod:@"POST"];
NSData *respData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error: nil];
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:WcfSeviceURL completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (error)
{
}
else
{
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:data
options:NSJSONReadingMutableContainers
error:&error];
NSString *isSuccessNumber = (NSString*)[json objectForKey:@"InsertEmployeeMethodResult"];
}
}];
[task resume];