( ).
. ARC . dealloc , . , , .
, . dealloc, .
, , , , .
...
id object = getMeSomeObject();
dealloc, . , , , , .
A __weak reference - , AS LONG AS OBJECT LIVES. , __weak, , . dealloc(), __weak nil.
, _weak . , , , dealloc. , dealloc , .
, , __strong , , .
...
[_request setCompletionBlock:^{
[self setResponseString:_request.responseString];
[[MyAppDelegate getQueue] addOperation:_operation];
}];
, , self. , , . ...
__weak SelfType *weakSelf = self;
[_request setCompletionBlock:^{
SelfType *strongSelf = weakSelf;
if (strongSelf) {
[strongSelf setResponseString:_request.responseString];
[[MyAppDelegate getQueue] addOperation:_operation];
} else {
}
}];
, self, ... . ? _request _operation . , self.
...
__weak SelfType *weakSelf = self;
[_request setCompletionBlock:^{
SelfType *strongSelf = weakSelf;
if (strongSelf) {
[strongSelf setResponseString:strongSelf->_request.responseString];
[[MyAppDelegate getQueue] addOperation:strongSelf->_operation];
} else {
}
}];
, , " ", .
, self, self dealloc, .
, , strongSelf , weakSelf. ...
if (weakSelf) {
[weakSelf doSomething];
}
strongSelf = weakSelf;
, self, , self deallocs , - self , - - .