I am trying to mockj a segmented control and I am getting crashes, any suggestions?
NSInteger selectedSegment = 2;
id segmentedControlMock = [OCMockObject niceMockForClass:[UISegmentedControl class]];
[[[segmentedControlMock stub] andReturn:OCMOCK_VALUE(selectedSegment)] selectedSegmentIndex];
I get a crash as soon as i call selectedSegmentIndex on my mock object:
Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘Expected invocation with object return type.’
You need to use
andReturnValue: