This question is similar to ios NSError types but the solution described there didn't work and I believe it isn't quite what I need.
I have a method that takes performs an asynchronous call and then invokes a completion block. When I try to pass the NSError ** to the completion block, I get this error:
Sending 'NSError *const __strong *' to parameter of type 'NSError *__autoreleasing *' changes retain/release properties of pointer
The code is as follows:
+(void) agentWithGUID:(NSString *) guid completion:(void (^)(AKAgentProfile * agentProfile, NSError ** error)) completionBlock
{
dispatch_queue_t requestQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(requestQueue, ^{
NSString * parameterizedUrl = [AKAgentProfileEndPoint stringByAppendingString:guid];
NSURL *url = [NSURL URLWithString:parameterizedUrl];
NSData *data = [NSData dataWithContentsOfURL:url];
NSError * error = nil;
AKAgentProfile * agentProfile = [[[AKAgentFactory alloc] init] agentProfileWithData:data error:&error];
dispatch_async(dispatch_get_main_queue(), ^{
completionBlock(agentProfile,&error);
});
});
}