첫 번째 것은 표준 할당이고 두 번째는 autorelease
d 개체를 반환하는 클래스 메서드를 의미합니다.
컨트롤러 (또는 viewController) 안에이 코드가 있다고 가정하면 메서드가 끝나면 request
개체가 할당 해제됩니다. 컨트롤러 내부에서 해당 객체에 대한 참조를 유지해야 할당이 해제되지 않습니다.
그래서, 당신의 인터페이스 정의 : 둘 이상의 요청이있는 경우
@interface MyController : UIViewController {
ASIHTTPRequest *request;
// ...
}
@property (nonatomic, retain) ASIHTTPRequest *request;
@end
그리고 그런데 다음 구현
@implementation MyController
@sinthetyze request;
- (void) aMethodThatInstantiatesYourRequest { // using self.request means that we use the accessory method, which involves a retain call
self.request = [[ASIHTTPRequest alloc] initWithURL:myURL];
// ...
[request release];
// or using the autoreleased object
self.request = [ASIHTTPRequest requestWithURL:myURL];
}
- (void) dealloc { // don't forget to release the request object
[request release];
[super release];
}
,을 사용하는 것이 좋을 것이다 네트워크 큐이므로 다양한 단일 요청 대신 큐에 대한 참조를 유지해야합니다.
See this gist은 ASINetworkQueue
을 사용합니다.
더 나은 답변을 위해 전체 코드를 게시하십시오. –