Skip to content
This repository has been archived by the owner on Apr 22, 2019. It is now read-only.

Incorrect use of resolveClassMethod: #94

Open
newacct opened this issue Mar 12, 2014 · 2 comments
Open

Incorrect use of resolveClassMethod: #94

newacct opened this issue Mar 12, 2014 · 2 comments

Comments

@newacct
Copy link

newacct commented Mar 12, 2014

In HPGrowingTextView.m, line 292, it says:

if ([UIView resolveClassMethod:@selector(animateWithDuration:animations:)])

This is wrong, because resolveClassMethod: is used to ask the class to dynamically add a class method to the class that wasn't already in the class. However, animateWithDuration:animations: is a regular class method that is always loaded in the class. Since it's already loaded, resolveClassMethod: will return NO, and the code under it is always skipped.

In reality, what it looks like you wanted to do was check whether the class has this method. To do that, you should instead do:

if ([UIView respondsToSelector:@selector(animateWithDuration:animations:)])

(or, for the method that's actually being used in the code after,

if ([UIView respondsToSelector:@selector(animateWithDuration:delay:options:animations:completion:)])

)

@zoyag
Copy link

zoyag commented Mar 26, 2014

Agree. Just now I ran the demo and find that it never go into the "if" branch. Replace with respondsToSelector: is OK.

@auibrian
Copy link

Agree. Not entirely sure what I was thinking when I wrote that. I would actually go further and state that the entire if can be removed and the code can just use block based animations only. The entire point of that section was to support pre iOS 4.0 devices which is no longer necessary.

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

No branches or pull requests

3 participants