この質問はios NSError typesと似ていますが、そこに記載されている解決策は機能しませんでした。かなり必要なものです。'NSError * const autoreleasing *'型のパラメータに 'NSError * const __strong *'を送信すると、ポインタの保持/解放のプロパティが変更されます
私は、非同期呼び出しを実行してから完了ブロックを呼び出すメソッドを持っています。私は完了ブロックに** NSErrorを渡すしようとすると、私はこのエラーを取得する:次のように
Sending 'NSError *const __strong *' to parameter of type 'NSError *__autoreleasing *' changes retain/release properties of pointer
コードは次のとおりです。値ではなく、参照することにより
+(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);
});
});
}
あなたは、ポインタとポインタの対の関係を誤解しています。 – Andy
Andy:私はそれが後でかなり明白であることを理解するために私をしばらく時間がかかることを認めます! –