ios - ALAssetsLibrary resultBlock weak or strong reference -


for call

[library assetforurl:referenceurl resultblock:^(alasset *asset){...} 

if pass image imageview, should pass imageview weak reference or should strong reference? can ever go wrong passing weak reference? weak reference mean

__weak myvc *weakself = self;  .... weakself.myimageview... 

block retains object reference , in turn create retain cycle. in above code snippet, block creates retain cycle, need use weak reference break retain cycle as

 __weak typeof(self) *weakself = self; 

or can implement in following way

__block myvc *blockself = self; 

and reference blockself inside block.

this avoids cycle, because blockself not retained


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -