0

私は現在postNotification、このようにスパイしています

__block KWCaptureSpy *notificationSpy = [[NSNotificationCenter 
defaultCenter] captureArgument:@selector(postNotification:) atIndex:0];

問題は、通知名が異なる複数の通知があることです。別の通知のスパイの引数にアクセスするにはどうすればよいですか。

たとえば、通知 1 と通知 2 があるとします。スパイ引数は通知 1 をキャプチャしますが、通知 2 をキャプチャすることはできません。

これをどのように行うことができるかについてのアイデアはありますか?

4

2 に答える 2

0

私が最終的に使用した解決策は

__block NSMutableArray *notifications = [[NSMutableArray alloc] init];
        [[NSNotificationCenter defaultCenter] stub:@selector(postNotification:) withBlock:^id(NSArray *params) {
            [notifications addObject:params[0]];
            return nil;
        }];
于 2015-05-20T20:16:46.820 に答える