Reputation: 121
@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");
});
}
When I set a breakpoint in __block NSDate *noUse = nil;
and call doSomething
, Xcode locates the line __block NSDate *noUse = nil
.
Upvotes: 0
Views: 58
Reputation: 19880
I had a similar problem in the past. Turning off compiler optimizations for debug builds (-O0
) fixed it for me.
Upvotes: 2