My question is pretty simple: are gesture recognizers and KVOs cleared when UIViewController is set to nil?
I have a project where the user can create and delete some complex UIViewController based instances. These are stored in an NSMutableArray.
If I just delete the instance from the array and then set it to nil (which I guess is superfluous) will all the @properties of the instance get cleared (assuming there are no other references to them)?
EDIT
I get the alert (error) below when I don’t manage the KVOs – so I guess the answer is ‘no’
An instance 0xce26d40 of class Track was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here’s the current observation info:
(
Context: 0x0, Property: 0x7530300>
Context: 0x0, Property: 0x75320f0>
An object owns its ‘@properties’ (assuming that they are
strongorretain). And a view owns any gesture recognizers that are added to it. So when the object is deallocated, its properties and recognizers will be released, and deallocated if no one else owns them.Key value observers and notification observers need to be manually unsubscribed before they get deallocated.