自从我添加了这个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
然后我的代码运行良好,但我觉得uneasy关于不使用错误..我应该做什么?
大概是因为你正在重复使用error
在完成处理程序中传递给您。它将被传递为__strong
然后你将它传递到需要的地方__autoreleasing
。尝试更改为以下代码:
...
[NSURLConnection sendAsynchronousRequest:req queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error){
dispatch_async(dispatch_get_main_queue(), ^{
NSError *error2 = nil;
NSDictionary *xmlDictionary = [XMLReader dictionaryForXMLData:data error:&error2];
...
});
}];
...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)