所以我開始在我的[viewDidLoad]在UIViewController上的ASIFormDataRequest。刪除dealloc上的委託沒有實例變量
ASIFormDataRequest *detailRequest = [ASIFormDataRequest requestWithURL:url];
detailRequest.delegate = self;
[detailRequest startAsynchronous];
如果我的UIViewController在我的請求結束之前被釋放,我的應用程序崩潰。
如果我加我ASIFormDataRequest作爲一個實例變量例如
@property(nonatomic, retain) ASIFormDataRequest *detailRequest;
和零委託上的dealloc
-(void)dealloc {
if(self.detailRequest != nil) { self.detailRequest.delegate = nil; }
self.detailRequest = nil;
[super dealloc];
}
應用程序不再崩潰。
但我不認爲有必要爲此創建一個實例變量,特別是如果我有多個請求。
有沒有更好的方法來做到這一點?