1、使用了计时器NSTimer,没有销毁
if (adTimer != nil) {
[adTimer setFireDate:[NSDate distantFuture]];
[adTimer invalidate];
adTimer = nil;
}
2、delegate定义为属性的时候,使用weak修饰符
@property (nonatomic,weak) id<GLGrowCountViewDelegate> delegate;
3、使用到block的地方,注意使用弱引用,避免强引用
//解决block强引用问题 宏
#define WeakSelf(weakSelf) __weak __typeof(&*self)weakSelf = self;
#define StrongSelf(strongSelf) __strong __typeof(&*self)strongSelf = weakSelf;
WeakSelf(weakSelf);
[self progressHUDShowThenHideWithText:@"注册成功" Action:^{
GLBindWXViewController *vc = [[GLBindWXViewController alloc] init];
vc.isFromTeminalLogin = weakSelf.isFromTeminalLogin;
vc.isLogoutToLogin = weakSelf.isLogoutToLogin;
vc.isGuideToLogin = weakSelf.isGuideToLogin;
vc.isTouristToLogin = weakSelf.isTouristToLogin;
[weakSelf.navigationController pushViewController:vc animated:YES];}];
4、block中使用到了变量,把它定义为属性,用 weakself.属性 来调用
不用
@interface GLLevelDetailViewController ()
{
NSInteger currentTypeID;
}
@property (nonatomic,copy) NSString *currentTypeID;
WeakSelf(weakSelf);
self.detailMedalButton = [GLButton buttonWithUrlImageWithFrame:CGRectMake(SCREENWIDTH - 40.0f*widthIPhone6 - medal_w, SCREENHEIGHT - medal_w - 10.0*widthIPhone6, medal_w, medal_w) Url:nil PlaceholderImage:@"hz_pic_default.png" ActionBlock:^{
if ([GLSceneLessonDataManager sharedInstance].hzpic != nil) {
[weakSelf showBigDetailMedalWithUrl:[GLSceneLessonDataManager sharedInstance].hzpic PassStatus:weakSelf.isAllPass TypeID:weakSelf.currentTypeID];
}
}];