False positive on MissingNotificationCenterDetachment

Issue #26 on hold
Former user created an issue

If an objects observes several notifications, I often clean up with a for:

- (void)dealloc {
    for (NSString *name in @[kMBLocationManagerNotificationAuthorizationChangedName,
                             kMBLocationManagerNotificationLocationUpdatedName,
                             COIQRCodeScanned,
                             COIItemRedeemed,
                             COIUserLoggedInNotification]) {
        [[NSNotificationCenter defaultCenter] removeObserver:self name:name object:nil];
    }
}

Faux Pas doesn't seem to understand it and I get a false positive.

Comments (2)

  1. Ali Rantakari repo owner

    Thanks for reporting this. Is there any reason why you cannot use -[NSNotificationCenter removeObserver:] instead? It's much simpler and less error prone, and would sidestep this false positive.

  2. Log in to comment