Argument Captor for Objective-C

For my small projects Qmind and Qdesktop I needed a Objective-C counterpart of Mockito’s ArgumentCaptor. As far as I can see, OCHamcrest or OCMockito do not offer this functionality. Thus, I wrote an OCHamcrest matcher which does the job: ArgumentCaptor.zip

Example:

ArgumentCaptor *captor = argCaptor();

[someMock someMessage:someArgument];
[verify(someMock) someMessage:captor];

id argument = captor.argument;
assertThat(argument, is(someArgument));

BTW, I’m using the ARC.

Tags: cocoa testing