OCMock - partial mocking [UIAlertView alloc]
问题 I'm having an issue with the OCMock framework for iOS. I'm essentially trying to mock UIAlertView 's initWithTitle:message:delegate ... method. The example below doesn't work in the sense that the stubbed return value isn't returned when I call the initWithTitle method. UIAlertView *emptyAlert = [UIAlertView new]; id mockAlert = [OCMockObject partialMockForObject:[UIAlertView alloc]]; [[[mockAlert stub] andReturn:emptyAlert] initWithTitle:OCMOCK_ANY message:OCMOCK_ANY delegate:nil