首页 > 其他 > 详细

Block笔记

时间:2019-10-29 19:09:57      阅读:61      评论:0      收藏:0      [点我收藏+]

此处不可以使用strongself和self会导致内存泄露,list就是typeList,会持有UserRepeatClickSelectIndexBlock,UserRepeatClickSelectIndexBlock持有self,self又会持有typeList   

 

typeof(self) __weak weakself = self;

        _typeList = [[ChooseEventList alloc] initWithFrame:CGRectMake(0, 0, YDScreenSize().width, DWF(45)) itemInfoArray:self.indexPageTypeList.copy configurationBlock:^(ChooseEventList *list) {

            typeof(weakself) __strong strongself = weakself;

            [list setUserRepeatClickSelectIndexBlock:^(ChooseEventList *list, NSInteger chooseIndex) {

                switch (weakself.indexPageTypeList[chooseIndex].integerValue) {

                    case YDIndexPageExamination:

                    case YDIndexPageWookShop:

                    {

                        [weakself setSelectedIndex:chooseIndex];

                    }

                        break;

                    default:

                        break;

                }

            }];

        }];

Block笔记

原文:https://www.cnblogs.com/yuxiaoyiyou/p/11760492.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!