block 中循环引用的问题

来源:互联网 发布:photoshop加密软件 编辑:程序博客网 时间:2024/05/29 11:04

#pragma mark -- 循环引用 //----------------------------------------------------------------------------------------------------

/*

    某些block中,使用self会造成循环引用


    __weak AppDelegate *weakSelf = self;

    dispatch_async(mainQueue, ^(void) {

        AppDelegate *strongSelf = weakSelf;

        if (strongSelf != nil){

            [strongSelf.myTimer invalidate];

            [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskIdentifier];

            strongSelf.backgroundTaskIdentifier = UIBackgroundTaskInvalid;

        }

    });


    __unsafe_unretained contentsViewController* yqContentsViewController = self;

    [_threeView reminderBlock:^{

        [_alertView setMessage:@"本章节内容暂时为空"];

        [_alertView show];

        [NSTimer scheduledTimerWithTimeInterval:1.0f target:yqContentsViewController selector:@selector(alertDismissed) userInfo:nil repeats:NO];

    }];

 */


0 0