我正在使用为处理 ARC 和非 ARC 项目而设置的XMLRPC 库。当我尝试向它传递一个 NSError 对象时,我收到了错误:
Implicit conversion of an Objective-C point to 'NSError *_autoreleasing *' is disallowed with ARC
和一个警告:
Incompatible point types sending 'NSError *_strong' to parameter of type 'NSError *_autoreleasing *'
这是方法:
+ (XMLRPCResponse *)sendSynchronousXMLRPCRequest: (XMLRPCRequest *)request error: (NSError **)error {
NSHTTPURLResponse *response = nil;
#if ! __has_feature(objc_arc)
NSData *data = [[[NSURLConnection sendSynchronousRequest: [request request] returningResponse: &response error: error] retain] autorelease];
#else
NSData *data = [NSURLConnection sendSynchronousRequest: [request request] returningResponse: &response error: error];
#endif
if (response) {
NSInteger statusCode = [response statusCode];
if ((statusCode < 400) && data) {
#if ! __has_feature(objc_arc)
return [[[XMLRPCResponse alloc] initWithData: data] autorelease];
#else
return [[XMLRPCResponse alloc] initWithData: data];
#endif
}
}
return nil;
}
这是我的尝试:
NSError *myError;
XMLRPCResponse *serverResponse = [XMLRPCConnection sendSynchronousXMLRPCRequest:request error:myError];
我想我不熟悉
#if
语法,但我猜它的行为就像一个常规的 If 语句?
我还启用了 ARC:
我应该重做 XMLRPCResponse 方法以删除对非 ARC 项目的处理,还是有原因导致我收到错误/警告?