3 ms·
Not sure if declaring weak objects all the time is a good practice, you can introduce silent bugs due to an object deallocating unintentionally in scope. Apple
by pixel_tracing 4y ago
Not sure if declaring weak objects all the time is a good practice, you can introduce silent bugs due to an object deallocating unintentionally in scope. Apple actually recommends using strong with proper architecture and relationships between objects.
See https://developer.apple.com/wwdc21/10216 https://developer.apple.com/wwdc21/10216
- ChrisMarshallNY 4y agoReference loops are also “silent” bugs. They are the worst kind of silent, because they usually stay hidden until long after the bug was introduced. My way forces me to deal with the bug, very close to causing it. The bugs aren’t really silent. If the code doesn’t get executed (because of all my guards and whatnot), it’s still a bug. It becomes apparent, quite quickly, and is easier to find. I just put a breakpoint in the unexecuted code, and watch it not happen. Lot better than trying to read tea leaves with Instruments, a month after causing the loop. The issue still happens, but it does so, in a way that is predictable. It’s like deliberately filing weak points into a support strut, so that breaks happen in a known place. The problem isn’t the break, but the orthogonal shear that happens at that point, and the weak point simply forces the break to happen in a place that it can be contained. It almost never happens, but when it does, it saves me a great deal of time. That’s the old McConnell thing about finding bugs near the point of introduction.