objective c - Will the block contains references to self? -


-(void) vaftermainvariable {     __weak bggeneralcatalogview * weakself=self;     [_loaionebyone vloadstuffswithurlblock:^(){         nsstring * url= [weakself strgeturltodownloadstuffs];         return url;     } andpermatoastmessage: @"loading catalog" andcompletionblock:^{}];     //[self.loaionebyone vloadstuffswithurlblock:<#^nsstring *(void)blurl#> andpermatoastmessage:<#(nsstring *)#> andcompletionblock:<#^(void)completionblock#>] }  -(nsstring *) strgeturltodownloadstuffs {     nsstring * url = [bgmakeurl urlforgetcatalogid:self.ararray];     return url; } 

i uses weakself in block. yet, weakself refer function call self.ararray

so block has strong pointer self? when self, viewcontroller gone navigationcontroller deallocated soon?

to exact, block not refer self. block refer weakself calls method refer self. self in method weakself.

basically followed this:

- (void)dealloc {     [_loaionebyone vcancelallstuffs]; } 

and turns out dealloc not called until after block finish. block must have contained self. how?

also how know object still refer object?

the object refer object should uinavigationcontroller object. next 1 block executing on stack.

weakself needs block variable. when block copied, creates own variable containing copy of weakself, , copy isn't weak.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -