On May 17, 2015, at 23:59 , Britt Durbrow <bdurb...@rattlesnakehillsoftworks.com> wrote: > > My understanding of retainCount is that it’s basically considered “taboo” > because trying to use it without knowing exactly what you are doing tends to > lead to pitfalls, and most people looking at it tend to think it means > something that it doesn't.
You’re right to be cautious, but you’ve come to the wrong conclusion. From OS X 10.0 to 10.5 (and beyond for numerous apps), memory was managed manually with ‘retain’ and ‘release’, and that certainly is “using” the retain count. What was frowned upon was reckless *reasoning* about retain counts: “If the retain count is such and such, and I do so and so, then XYZ will happen”. Those sorts of arguments tended to blow up in peoples’ faces**. It is, however, valid to increment the retain count of a valid (that is, live) object, and to reason that the object will stay alive at least until you decrement the retain count. This is sufficient for your scenario. ** For example: "If the retain count is 1, and I decrement it, the object will be deallocated.” This is incorrect reasoning, because any code that checks and decrements the retain count is subject to side effects that affect the outcome. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com