码迷,mamicode.com
首页 > 其他好文 > 详细

block 中循环引用的问题

时间:2015-06-18 13:43:04      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:ios   objective-c   

#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];

    }];

 */


block 中循环引用的问题

标签:ios   objective-c   

原文地址:http://blog.csdn.net/ios14311034/article/details/46545795

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!