periphery icon indicating copy to clipboard operation
periphery copied to clipboard

Notification token unused warning should be ignored by default

Open ZeroOnet opened this issue 3 years ago • 0 comments

I registered a notification handler with a token, I don't need to access it again because Notification Center will remove it automatically if token was destoried.

Code example:


class A {
    var token: NSObjectProtocol?

    func addNoti() {
        token = NotificationCenter.default.addObserver(
            forName: UIApplication.didBecomeActiveNotification,
            object: nil,
            queue: .main
        ) { _ in
            // do something
        }
    }
}

In periphery 2.9.0, It gives me a warning 「Property 'token' is assigned, but never used」This warning should be ignored by default.

ZeroOnet avatar Jun 22 '22 10:06 ZeroOnet