fix: Remove Unnecessary Synchronize in Dealloc #169
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Inspected all uses of dealloc method
MPApplication
Removed as synchronize has been unneeded since iOS 7
MPBackendController
Our in-app documentation provides full reasoning for this code as it supports our proxying of the app delegate.
MPSegment
Apple Docs ("A typical pattern is to register as an observer during the observer’s initialization (for example in init or viewDidLoad) and unregister during deallocation (usually in dealloc)") actually suggest including your removeObserver code in the dealloc: method. Adding the observer doesn’t cause a retain on the class object and using instruments I wasn’t able to find any leaks. If you have a .trace recorded from instruments showing it, that would be a huge help.
MParticleReachability & MPStateMachine by extension
This is the standard shared reachability code written by Apple used across multiple organizations. I agree we should update to the swift version when we update fully to Swift but for now it is appropriate to use.
Testing Plan
Ran through unit tests and putting code through its paces in a sample application. Also tested for leaks through instruments.
Master Issue
Closes https://mparticle-eng.atlassian.net/browse/SQDSDKS-4831