Friday, February 24, 2012 [Tweets]

Creating Retain Cycles by Misusing Assertions

Evadne Wu (via Kevin Ballard):

When you use NSAssert, ultimately the expanded code contains a reference to self and _cmd, inside whatever method the line was used. This also prohibits use of NSAssert in a block, because it creates a retain cycle. Just use NSCAssert which looks slightly wonky but does not require being used within an Objective-C method, and does not allow the programmer to accidentally create retain cycles.

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment