我正在使用来自https://github.com/ryanmaxwell/UIAlertView-Blocks的UIAlertView +块,它使用OCMock为UIAlertView添加了tapBlock属性。
id mockView = [OCMockObject mockForClass:[UIAlertView class]];
[[[mockView stub] andReturn:mockView] alloc];
// this works
[[mockView expect] setTapBlock:OCMOCK_ANY];
// this doesn't, it doesn't know what tapBlock is
[[mockResetPasswordView expect] tapBlock:OCMOCK_ANY];
tapBlock声明为@property (copy, nonatomic) UIAlertViewCompletionBlock tapBlock
。我也希望能够调用它并委托回原始方法。