NSURLResponse *response =[[NSURLResponse alloc] initWithURL:requestingURL
                                                   MIMEType:@"text/xml"
                                      expectedContentLength:-1
                                           textEncodingName:nil];

webData = [NSURLConnection sendSynchronousRequest:theRequest
                                returningResponse:response
                                            error:NULL];


我收到了编译器警告,指出不兼容指针类型的警告传递参数。我怀疑这是因为NSURLResponse参数是双星参数(NSURLResponse **)?

我在这里做错了什么?

最佳答案

回复已通过引用返回给您。

NSURLResponse *response = nil;
NSError *error = nil;
NSData *data = [NSURLConnection sendSynchronousRequest: request
                                returningResponse: &response
                                error: &error];


这是正确的调用方式,并通过引用获取响应和错误。

在上面的代码中,除了语法错误外,您还泄漏了响应对象。

关于iphone - Objective-C方法中的双星论证?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1210357/

10-10 20:38