//
//  RDSDeallocWatcher.m
//  RuiZhi
//
//  Created by RD on 2020/6/28.
//  Copyright © 2020 RDIOT. All rights reserved.
//

#import "RDSDeallocWatcher.h"

@implementation RDSDeallocWatcher

- (instancetype)initWithDeallocCallback:(dispatch_block_t)callback {
    self = [super init];
    if (self) {
        self.deallocCallback = callback;
    }
    return self;
}

// 关键代码，当该对象释放触发 dealloc 方法时，会去执行 callback 回调
- (void)dealloc
{
    DDLog(@"dealloc");
    
    if (self.deallocCallback) {
        self.deallocCallback();
    }
}

@end
