سؤال

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?

هل كانت مفيدة؟

المحلول

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];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top