开发者

What is the proper place to release a NSURLConnection in the following example?

开发者 https://www.devze.com 2023-03-09 02:37 出处:网络
I have the following statement in my viewWillAppear controller:开发者_开发问答 connectionInprogress = [[NSURLConnection alloc]initWithRequest:request delegate:self startImmediately:YES];

I have the following statement in my viewWillAppear controller:

开发者_开发问答
connectionInprogress = [[NSURLConnection alloc]initWithRequest:request delegate:self startImmediately:YES];

What is the proper place to release it? That is can I just do it in viewDidUnload or does it make more sense to do it in viewDidDissapear?

I guess the fundamental question here is that does viewDidUnload get called every time a viewDidDissapear gets called?


No viewDidUnload is paired with viewDidLoad and may never get called, which is why you should also release your instance variables in dealloc. viewDidUnload is called if the view controller is sent a memory warning.

You should release theNSURLConnection in the callback functions: connectionDidFinishLoading: and connection:didFailWithError:. Only one will be called.

Check out the Xcode documentation for URL Loading System Programming Guide : Using NSURLConnection.


Check the documentation, it'll be the fastest way

viewDidUnload
viewDidDisappear

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号