NSURLErrorDomain代码= -1012无法完成该操作 [英] NSURLErrorDomain Code=-1012 The operation couldn’t be completed
问题描述
从xcode运行代码时,出现以下错误.
I am getting the following error when running my code from the xcode.
Error Domain = NSURLErrorDomain代码= -1012操作无法完成.(NSURLErrorDomain错误-1012.)" UserInfo = 0x17166b740 {NSErrorFailingURLStringKey = https://..../move/resource/v1/user/me/activity/summary?start_date = 2015-01-21& end_date = 2015-01-14& detail = true }
Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x17166b740 {NSErrorFailingURLStringKey=https://..../move/resource/v1/user/me/activity/summary?start_date=2015-01-21&end_date=2015-01-14&detail=true, NSUnderlyingError=0x17405b630 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1012.)", NSErrorFailingURLKey=https://..../move/resource/v1/user/me/activity/summary?start_date=2015-01-21&end_date=2015-01-14&detail=true}
这是我的代码
NSString *urlSummaryString = [[NSString stringWithFormat: @"%@summary?start_date=%@&end_date=%@&detail=true", kMisfitCloudEndpoint, strStartDate,strEndDate] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
__block NSMutableDictionary *responseDict = [NSMutableDictionary dictionary];
__block NSError *error = nil;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlSummaryString] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20.0];
[request setValue:@"access_token" forHTTPHeaderField:self.misfitAccessToken];
[request setHTTPMethod:@"GET"];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if(connectionError){
// Handle the connection error
return ;
}}];
任何人都可以帮助我这里有什么问题吗?它与服务器上的SSL证书有关吗,并且与安全性有关.当我使用CocoaRestClient发出请求时,它可以正常运行.
Can any one help me what is wrong here. Is it something related to SSL Certificate on the server and is related to the security. When I use CocoaRestClient to make my request it works perfectly.
有人可以详细解释一下导致此问题的原因吗,或者是否有任何机构可以解决此问题.我必须使用[NSURLConnection sendAsynchronousRequest]
方法.我正在使用Xcode
6.1和ios
8.1.2
Can some body explain me in detail what cause this problem or if any body can have the solution for this. I have to use [NSURLConnection sendAsynchronousRequest]
method. I am using Xcode
6.1 and ios
8.1.2
推荐答案
这是 kCFURLErrorUserCancelledAuthentication 错误, -10xx错误属于 CFNetworkErrors 枚举. 这个常数的名字很不言而喻.服务器由于某种原因取消了身份验证
This is kCFURLErrorUserCancelledAuthentication error, -10xx errors are of the CFNetworkErrors enum. Name of this constant is pretty selfexplanatory. Server cancelled authentication for some reason
这篇关于NSURLErrorDomain代码= -1012无法完成该操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!