Domanda

I want to use OCMock such that whenever someMethod is called with any argument, it calls callBackMethod: with argument "dict", which is an NSDictionary. I found andCall:onObject: but that doesn't seem to let you pass an argument. Is there a way to get this desired behavior?

È stato utile?

Soluzione

You can use andDo: and execute whatever you want in the given block.

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

[[[yourMock stub] andDo:^(NSInvocation *invocation) {
    [anObject callBackMethod:dictionary];
}] someMethod];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top