__block __weak在回调里面引用对象 和修改对象

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#define WS(weakSelf)                __weak __typeof(&*self)weakSelf = self


@interface ScanQCodeController ()<AVCaptureMetadataOutputObjectsDelegate>

{
    NSTimer *_timer;
    AVCaptureSession *_session;
}
@end


//引用
            __weak  typeof(_session) weakSession = _session;
//引用加修改
            __block  __weak typeof(_timer) weakTimer = _timer;
            [Tools showIndicateViewInCenterWithTitle:@"未找" Duration:ShowMsgViewDefaultTime dismiss:^{
                weakTimer = [NSTimer scheduledTimerWithTimeInterval:.02 target:self selector:@selector(animation) userInfo:nil repeats:YES];
                [[NSRunLoop mainRunLoop] addTimer:weakTimer forMode:NSRunLoopCommonModes];
                //加载扫码
                [weakSession startRunning];
            }];