NSTimer Retains its Target?

Caught me out the other day – I didn’t realise that NSTimer would retain its target, meaning that my object that owned it didn’t deallocate before I invalidated the timer. Don’t let it catch you out!

Also, I found out that you can use [sourcecode language=”objc”]performSelector:withObject:afterDelay:[/sourcecode] instead of a timer in some cases. Note that the receiver will be retained until the selector is performed, so don’t let that catch you out either!

Be careful out there guys and gals, it’s a dangerous world đŸ™‚

Leave a Reply

Your email address will not be published. Required fields are marked *