Skip to content

Instantly share code, notes, and snippets.

@asmallteapot
Created October 30, 2013 22:56
Show Gist options
  • Save asmallteapot/7241750 to your computer and use it in GitHub Desktop.
Save asmallteapot/7241750 to your computer and use it in GitHub Desktop.
Returning BOOL values from mocked & stubbed methods using OCMock.
// @property (nonatomic) BOOL enabled;
// someObject = [OCMock partialMockForObject:[[SomeObject alloc] init]];
[[[mock stub] andDo:^(NSInvocation *invocation) {
BOOL enabled = someObject.enabled;
NSValue *returnValue = [NSValue valueWithBytes:&enabled objCType:@encode(BOOL)];
[invocation setReturnValue:&returnValue];
}] enabled];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment