Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does a message send cause a retain cycle warning in ARC, but a property set does not?

[self.foo setBlock:^{
    [self doSomething]; // causes warning
}];

versus

[self.foo setBlock:^{
    self.bar = baz;     // does not cause warning
}];

The warning being "Capturing self strongly in this block is likely to lead to a retain cycle."

Don't both lead to a strong reference?

like image 469
Aaron Avatar asked Jan 09 '13 22:01

Aaron


1 Answers

This is a compiler bug and you should file a bug report with Apple.

Both are the same, a.b = c is just a different way for writing [a setB: c]. If the compiler handles one differently from the other this is a bug.

like image 157
Sven Avatar answered Oct 22 '22 02:10

Sven