在iOS 9中,我使用基本的NSURLConnection命令使用网址https://s3.amazonaws.com/furniture.retailcatalog.us/products/2061/6262u9665.jpg.
NSOperationQueue *completionQueue = [NSOperationQueue mainQueue];
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
self.mURLSession = [NSURLSession sessionWithConfiguration:configuration delegate:nil delegateQueue:completionQueue];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://s3.amazonaws.com/furniture.retailcatalog.us/products/2061/6262u9665.jpg"]];
NSURLSessionDataTask *dataTask = [self.mURLSession dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSLog(@"%@",error);
}];
[dataTask resume];
Run Code Online (Sandbox Code Playgroud)
但得到这个错误
错误域= NSURLErrorDomain代码= -1200"发生SSL错误,无法与服务器建立安全连接." UserInfo = {NSLocalizedDescription =发生了SSL错误并且无法与服务器建立安全连接.,NSLocalizedRecoverySuggestion =您是否还要连接到服务器?,_kCFStreamErrorDomainKey = 3,NSUnderlyingError = 0x7c1075e0 {错误域= kCFErrorDomainCFNetwork代码= - 1200"(null)"UserInfo = {_ kCFStreamPropertySSLClientCertificateState = 0,_kCFNetworkCFStreamSSLErrorOriginalValue = -9802,_kCFStreamErrorCodeKey = -9802,_kCFStreamErrorDomainKey = 3,kCFStreamPropertySSLPeerTrust =,kCFStreamPropertySSLPeerCertificates = {type = immutable,count = 3,values =(0:1:2: }}}},_ kCFStreamErrorCodeKey …
我正在开发一个iOS应用程序,我必须在我的应用程序上分享WhatsApp上的图像.我找到了这段代码,但它只处理文本共享https://github.com/jberlana/JBWhatsAppActivity
我有一个方法,它采用类似这样的变量参数,参数以nil结尾.
-(void)manyParams:(NSString *)st, ... {
va_list argList;
va_start(argList,st);
id obj;
while ((obj = va_arg(argList, id))) {
NSLog(@"%@",obj);
}
va_end(argList);
return;
}
Run Code Online (Sandbox Code Playgroud)
我可以像这样直接调用它
[self manyParams:@"one",@"two",@"three",nil];
Run Code Online (Sandbox Code Playgroud)
如果我使用NSInvocation类来调用manyParams,那么我该怎么做呢
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setTarget:self];
[invocation setSelector:@selector(manyParams:)];
///NSString *one = @"one";
///[invocation setArgument:&one atIndex:2]; //////How to pass variable arguments like @"one",@"two",@"three", nil
[invocation invoke];
Run Code Online (Sandbox Code Playgroud)