이 질문은 ios NSError types과 유사하지만 거기에 설명 된 해결책이 작동하지 않으며 내가 필요한 것.'NSError * const autoreleasing *'유형의 매개 변수에 'NSError * const __strong *'을 보내면 포인터의 유지/해제 속성이 변경됩니다.
필자는 비동기 호출을 수행하고 완료 블록을 호출하는 메서드를 사용합니다.
이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 : 나도 인정한다. 나중에 꽤 명백한 것으로 밝혀진 것을 이해하는 데 시간이 걸린다. –