__weak NSBlockOperation *secondBlockOperation = [NSBlockOperation blockOperationWithBlock:^{
NSLog(@"%@",secondBlockOperation);
NSLog(@"this is the second block");
}];
__block __weak NSBlockOperation *secondBlockOperation = [NSBlockOperation blockOperationWithBlock:^{
NSLog(@"%@",secondBlockOperation);
NSLog(@"this is the second block");
}];
__block NSBlockOperation *secondBlockOperation = [NSBlockOperation blockOperationWithBlock:^{
NSLog(@"%@",secondBlockOperation);
NSLog(@"this is the second block");
}];
This is the code I cannot understand.I have found that the __block one will cause the memory leak.So the __block __weak one come into my mind.OK,there is no more leak at all.But when I custom a class with a block as a strong property,like this __weak Person *one = nil; one = [[Person alloc] initWithBlock:^{ NSLog(@"%@",one); }]; the weak assign warning showed.
To be honest,I don't understand the result when __block and __weak used together.__block value will be a pointer to a struct with forwarding pointer and the value pointer in it .So the weak is worked for the pointer to the __block struct or the pointer in the __block struct.and why __weak NSBlockOperation *secondBlockOperation have no warning??!