@property (nonatomic, copy) void(^block)();
- (void)viewDidLoad {
[super viewDidLoad];
self.block = ^{
NSLog(@"123");
};
void * a = (__bridge void *)(_block);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (a == _block) {
self.block();
}
});
self.block = ^{
NSLog(@"456");
};
}
不输出
@property (nonatomic, copy) void(^block)();
- (void)viewDidLoad {
[super viewDidLoad];
self.block = ^{
NSLog(@"123");
};
void * a = (__bridge void *)(_block);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (a == _block) {
self.block();
}
});
}
输出 123
网友评论