【发布时间】:2012-02-08 23:15:03
【问题描述】:
自从我添加了这个 async 请求后,我收到了一个 xcode 错误 Sending 'NSError *const __strong *' to parameter of type 'NSError *__autoreleasing *' changes retain/release properties of pointer
...
[NSURLConnection sendAsynchronousRequest:req queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error){
dispatch_async(dispatch_get_main_queue(), ^{
NSDictionary *xmlDictionary = [XMLReader dictionaryForXMLData:data error:&error];
...
});
}];
...
如果我使用error:nil,那么我的代码运行良好,但我对不使用错误感到不安。我该怎么办?
【问题讨论】:
-
如果你实际上没有对错误做任何事情,你也可以只传递 NULL。您通常可以检测到是否发生了错误,因为该方法返回 nil,因此您不会错过发生错误的事实。
标签: ios