On Apr 3, 2014, at 8:22 PM, Varun Chandramohan <varun.chandramo...@wontok.com> wrote: > Interestingly, the static code analysis find the call of "retain" as a leak. > How do I address this issue? What is correct way to rewrite this code to make > static analyser understand that I will be releasing the resource? If I > removed the retain count, the warning goes away but it contents is freed and > I crash.
As Graham says, the problem is that you’ve declared ‘contents’ assign, but you're actually working with it like a strong property: you’re establishing an invariant that the object in that property is held at +1. Presumably you even release it in your -dealloc. If anything else ever assigns to this property, it’ll have to manually release the current value and then pass a object at +1 into the setter. (If nothing else ever assigns to this property, you should make it readonly.) Just make it a strong property and either (1) pass the value to the setter at +0 or (2) make the property readonly and assign the +1 value directly to the ivar. John. _______________________________________________ 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