user1802143
user1802143

Reputation: 15702

iOS OCMock call back method with parameter

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?

Upvotes: 1

Views: 468

Answers (1)

e1985
e1985

Reputation: 6279

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];

Upvotes: 1

Related Questions