Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCMock 3: Text field mocking fails in strange ways #127

Open
patrickhartling opened this issue Jul 29, 2014 · 6 comments
Open

OCMock 3: Text field mocking fails in strange ways #127

patrickhartling opened this issue Jul 29, 2014 · 6 comments

Comments

@patrickhartling
Copy link
Contributor

I encountered an unexpected problem where simply creating a partial mock of an instance of UITextField contained within an other object results in this error if ‑resignFirstResponder is sent to the UITextField object:

-[OCMockTextFieldTest testCreateMock] failed: -[UITextInputTraits resignFirstResponder]: unrecognized selector sent to instance 0x102b05ba0

That was produced by running the test class I created to show the issue. I don't know the significance of this, but if the test method is written as follows, no error occurs:

- (void)testCreateMock
{
    UITextField *const textField = [UITextField new];
    id mockObject = OCMPartialMock(textField);
    [textField resignFirstResponder];
}
@erikdoe
Copy link
Owner

erikdoe commented Aug 20, 2014

With the recent changes made in response to some of the other issues reported this problem seems to have been fixed, too. Could you retry whether it works for you now?

@patrickhartling
Copy link
Contributor Author

This issue still happens as of 8d323b3.

@rex-remind101
Copy link

+1

2 similar comments
@realf
Copy link

realf commented Jan 19, 2016

+1

@jakunico
Copy link

+1

@PatrickNLT
Copy link

It may be an issue with UITextField not being KVC-compliant. See http://stackoverflow.com/questions/6617472/why-does-valueforkey-on-a-uitextfield-throws-an-exception-for-uitextinputtraits for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants