wwmz/WMZCode

timer 没释放。代码我给你改好了

Opened this issue · 0 comments

【你无非是想单例,是对的,但是单例化和销毁是下面这么写的,只有销毁才会调用dealloc,这个时机才会关闭timer】

  • (void)dealloc{
    NSLog(@"%@",JobsLocalFunc);
    if (timer) {
    dispatch_source_cancel(timer);
    }
    // [[NSNotificationCenter defaultCenter] removeObserver:self];
    }
    /// 单例化和销毁
    +(void)destroySingleton{
    static_codeViewOnceToken = 0;
    static_codeView = nil;
    }

static WMZCodeView *static_codeView = nil;
static dispatch_once_t static_codeViewOnceToken;
+(instancetype)sharedInstance{
dispatch_once(&static_codeViewOnceToken, ^{
static_codeView = WMZCodeView.new;
});return static_codeView;
}