iOS OCMock使用参数回调方法

时间:2013-08-09 23:09:27

标签: ios stub ocmock

我想使用OCMock,以便每当使用任何参数调用someMethod时,它会使用参数" dict"调用callBackMethod:,这是NSDictionary。我找到了andCall:onObject:,但似乎没有让你通过论证。有没有办法达到这个理想的行为?

1 个答案:

答案 0 :(得分:1)

您可以使用andDo:并在给定的块中执行您想要的任何内容。

id yourMock;//...
NSDictionary *dictionary;//...
id anObject;//...

[[[yourMock stub] andDo:^(NSInvocation *invocation) {
    [anObject callBackMethod:dictionary];
}] someMethod];