Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conform to new swiftlint rules #119

Merged
merged 5 commits into from
Mar 27, 2017
Merged

Conform to new swiftlint rules #119

merged 5 commits into from
Mar 27, 2017

Conversation

justinswart
Copy link
Contributor

The latest swiftlint introduced some new rules, this PR just addresses them.

Most notable new rule is discarded_notification_center_observer. Turns out all of our block/closure Notification observers were leaking?

Most of the others are fairly innocuous but nice to have them tidied up.

@@ -154,6 +154,7 @@ internal final class AppDelegate: UIResponder, UIApplicationDelegate {
.observeForUI()
.observeValues { [weak self] in self?.findRedirectUrl($0) }

//swiftlint:disable discarded_notification_center_observer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've disabled this here seeing as AppDelegate lives forever?

@mbrandonw
Copy link
Contributor

Most notable new rule is discarded_notification_center_observer. Turns out all of our block/closure Notification observers were leaking?

This isn't needed in iOS 9+. From https://developer.apple.com/library/content/releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_11.html:

NSNotificationCenter and NSDistributedNotificationCenter no longer send notifications to registered observers that may be deallocated. If the observer is able to be stored as a zeroing-weak reference the underlying storage stores the observer as a zeroing weak reference. Alternatively, if the object cannot be stored weakly (because it has a custom retain/release mechanism that would prevent the runtime from being able to store the object weakly) the object is stored as a non-weak zeroing reference. This means that observers are not required to un-register in their deallocation method.

Copy link
Contributor

@mbrandonw mbrandonw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, we can revert all the notification center stuff and disable the rule in our swiftlint.

then this should be good to go

@justinswart
Copy link
Contributor Author

Ah, I should read the docs occasionally :)

@justinswart justinswart merged commit 3d82263 into master Mar 27, 2017
@mbrandonw mbrandonw deleted the swiftlint_fixes branch March 29, 2017 13:40
@justinswart justinswart restored the swiftlint_fixes branch February 27, 2018 18:00
@justinswart justinswart deleted the swiftlint_fixes branch January 3, 2019 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants