Objective-C compiler should flag calls to [NSTimer invalidate] in dealloc
| Originator: | dmunsie | ||
| Number: | rdar://21591351 | Date Originated: | 29-Jun-2015 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | |
| Classification: | Enhancement | Reproducible: | N/A |
Summary: Since calling invalidate on a NSTimer object in dealloc is almost always a mistake, the Objective-C compiler should output a warning anytime invalidate is called from dealloc. Rationale: while the NSTimer is valid, the NSTimer object holds a strong reference to the target object. Since the ref count is not zero, dealloc will never be called and therefore, invalidate will never be called either. Steps to Reproduce: 1. Create an object that creates a NSTimer and assigns itself as the target. 2. Call invalidate in the dealloc method. Expected Results: Compiler outputs a warning that invalidate will never be called since a strong reference is held by the NSTimer object. Actual Results: No compiler warning. Version: Notes: Configuration: Attachments:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!