"Undetached delegate" does not consider APIs in older SDK versions

Issue #94 new
JinZhuHuang created an issue

from iOS 9 and later, the SDK classes's delegate property changed to "weak". If I have an SDK instance holding a delegate to my Class instance, an not set it to nil in dealloc, Fauxpas won't notice that.

As shown in the following code , Fauxpas won't raise a "Undetached delegate" warning. This code works fine on iOS 9 and later, but may crash on lower iOS versions!

@interface ViewController () <UIScrollViewDelegate>
@property (retain) UIScrollView *scrollView;
@end

......
- (void)viewDidLoad {
    [super viewDidLoad];
    self.scrollView.delegate = self;
}

- (void)dealloc
{
    [_scrollView release];

    [super dealloc];
}

Comments (2)

  1. Ali Rantakari repo owner

    Thanks for reporting this.

    This is a good point, and I agree that it would be very useful for Faux Pas to emit a diagnostic in these cases. The current behavior is due to the fact that Faux Pas only sees the SDK you are developing against, and has no knowledge of the "history" of the API in question (in this case UIScrollView.delegate). Being able to warn about cases like this would require gathering such a historical record across the entire system API surface and matching against that as well, which is why I'm marking this as an enhancement here.

  2. Log in to comment