简体   繁体   中英

how to prevent ARC memory leak on iOS

how to prevent the memory leak on code as shown as below:-

[self.teacher requestData:^(NSData *data) {
self.name = @"case";
}];

i had tried googled regarding this issue but not worked. Would be thankful if anyone could point me of the correct direction

Try this :-

__weak typeof(self) weakSelf = self;
[self.teacher requestData:^(NSData *data) {
    typeof(weakSelf) strongSelf = weakSelf;
   strongSelf.name = @"case";
}];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM