On 19 Feb 2010, at 18:06, Clark Cox wrote: > On Fri, Feb 19, 2010 at 8:15 AM, Roland King <r...@rols.org> wrote: >> why would that leak it? Those calls are paired, a table enters editing mode, >> the variable is set and what it's set to is retained, when the table exits >> editing mode again the cached value is released and nil'ed. The variable is >> also released in dealloc (not shown here). I do not know of a case where >> setEditing is called with YES twice without an intervening setEditing:NO. > > Just because you don't know of a case doesn't mean that you shouldn't > be prepared for it. If I were you, I would do something like:
I agree. Except I would create an accessor for preEditPath so the code becomes: > -(void)setEditing:(BOOL)editing animated:(BOOL)animated { if(editing) { [self setPreEditPath: [[self tableView] indexPathForSelectedRow]]; } [super setEditing: editing animated: animated]; if(!editing && [self preEditPath] != nil) { [[self tableView] selectRowAtIndexPath: preEditPath animated: YES scrollPosition: UITableViewScrollPositionNone]; [self setPreEditPath: nil]; } } > That is, release preEditPath in the editing case before setting it, to > avoid a leak in the case you are called twice with a value of YES, as > well as avoid passing a nil preEditPath to > -selectRowAtIndexPath:animated:scrollPosition: in the case that you > are called twice with a value of NO. > > -- > Clark S. Cox III > clarkc...@gmail.com > _______________________________________________ > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net > > This email sent to a...@jeremyp.net ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ _______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com