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
Post a Comment