@interface DemoClass()
@property dispatch_queue_t queue;
@end
@implementation DemoClass
-(instancetype)init
{
if (self = [super init]) {
self.queue = dispatch_queue_create("ccccc", DISPATCH_QUEUE_SERIAL);
}
return self;
}
-(void)notCallFunction
{
dispatch_async(self.queue, ^{
__block NSDate *noUse = nil;
NSLog(@"notCallFunction:%@",noUse);
});
}
-(void)doSomething
{
__block NSError *error = nil;
dispatch_async(self.queue, ^{
error = nil;//when add this line,notCallFunction can enter "__block NSDate *noUse = nil" break point
NSLog(@"doSomething");
});
}
当我在 __block NSDate *noUse = nil;
中设置断点时
并调用 doSomething
,Xcode 找到行 __block NSDate *noUse = nil
。
最佳答案
我以前遇到过类似的问题。关闭调试构建的编译器优化 (-O0
) 为我修复了它。
关于ios - 为什么 Xcode 使用 __block 进入未调用的函数断点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29491105/