用户登录
用户注册

分享至

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

  • 作者: 蛋吊红肿
  • 来源: 51数据库
  • 2022-08-17
#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];
            }];
软件
前端设计
程序设计
Java相关