(someone, please edit the name, it is clear that I am not very good with jargon)
So, let's say I have an object called DataRequester
whose task is to create an NSURLConnection
, as well as its delegate. I instantiate an object from my root view controller, and also provide a callback block (which is a DataRequester
property). When the NSURLConnection
finished loading, I call the callback and pass in the NSData
as a parameter.
Now, in my root view controller where the completion block is defined, I want to save the NSData
in the NSData (strong,nonatomic) *responseData
property of the root view controller. My question is: in the callback should I use
weakSelf.responseData = [NSData dataWithData:passedInData];
or I can just use:
weakSelf.responseData = passedInData;
(Where RootViewController * __weak weakSelf = self)
Also, the project uses ARC.
A brief explanation of the correct answer would be appreciated and would help me understand how memory is managed (I did a bunch of reading, but a practical example / explanation would come a long way for me).
source share