プロジェクト全体でObjective-Cブロック内の「自己」または下線付きのパラメータの使用をチェックできるスクリプト(またはRegex)がありますか?Objective-Cのブロック内で「self」コールのインスタンスをスキャンしますか?
コードを移動するときにこれらを偶然スキミングすることが可能です。誰かがそれらを避けるためにもっと防弾方法を持っているのだろうかと思っていました。
EDIT:たとえば、機能Aは旗を投げるが、Bは機能していない...だけ^{}
内では、この場合には問題ないはずです。
- (void)a
{
^
{
NSLog(@"This should throw a flag: %@ ... %@ ... %@", [self someProperty], _someProperty, self.someProperty);
^(NSInteger number)
{
NSLog(@"This should also throw a flag: %@ ... %@ ... %@", [self someProperty], _someProperty, self.someProperty);
}(0);
}
}
- (void)b
{
NSLog(@"This is OK: %@ ... %@ ... %@", [self someProperty], _someProperty, self.someProperty);
__weak NSObject *weakSelf=self;
^
{
NSLog(@"This is also OK.", [weakSelf someProperty], weakSelf, weakSelf.someProperty);
^(NSInteger number)
{
NSLog(@"This, too, is OK.", [weakSelf someProperty], weakSelf, weakSelf.someProperty);
}(0);
}
}
なぜブロック内の 'self'へのアクセスを探したいのですか? –