When to call release on NSURLConnection delegate?

前端 未结 5 1947
挽巷
挽巷 2021-01-05 22:44

When passing a delegate to the a NSUrlConnection object like so:

[[NSURLConnection alloc] initWithRequest:request delegate:handler];
         


        
5条回答
  •  心在旅途
    2021-01-05 23:34

    Your need to release the connection, not the delegate. The NSURLConnection class I think does not retain the delegate, which is why you get a crash when you try and release it.

    The two places to release the connection are connection:DidFinishLoading, and connection:didFailWithError.

提交回复
热议问题