Navigation Menu

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

Implement -respondsToSelector: when using -rac_signalForSelector: on KVO'd target #891

Merged
merged 13 commits into from Oct 28, 2013

Conversation

kastiglione
Copy link
Member

Fixes #889

When calling -rac_signalForSelector: on an object that has been KVO'd, we implement the selector directly on KVO's dynamic subclass. However, the default implementation of -respondsToSelector: bases its result on the class returned by -class, which KVO overrides to return the original class, not its custom subclass.

This change redefines -respondsToSelector: when calling -rac_signalForSelector: on a target that has been KVO subclassed.

@@ -201,9 +235,13 @@ static Class RACSwizzleClass(NSObject *self) {
// Just swizzle -forwardInvocation: in-place. Since the object's class
// was almost certainly dynamically changed, we shouldn't see another of
// these classes in the hierarchy.
//
// Additionally, swizzle -respondsToSelector: becuase the default
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because*

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆 😂

Who knew that spelling because wrong could turn out to make my day.

@Coneko
Copy link
Member

Coneko commented Oct 25, 2013

🍰

@kastiglione
Copy link
Member Author

🍨

@kastiglione
Copy link
Member Author

Easy as 1-2-3, A-C-B.

@ghost ghost assigned jspahrsummers Oct 25, 2013
@@ -87,6 +87,40 @@ static void RACSwizzleForwardInvocation(Class class) {
class_replaceMethod(class, forwardInvocationSEL, imp_implementationWithBlock(newForwardInvocation), "v@:@");
}

static void RACSwizzleRespondsToSelector(Class class) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird spacing here.

@@ -201,9 +235,13 @@ static Class RACSwizzleClass(NSObject *self) {
// Just swizzle -forwardInvocation: in-place. Since the object's class
// was almost certainly dynamically changed, we shouldn't see another of
// these classes in the hierarchy.
//
// Additionally, swizzle -respondsToSelector: because the default
// implementation is ignorant of methods added to this class.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*may be ignorant (:trollface:?)

@jspahrsummers
Copy link
Member

🎩

@kastiglione
Copy link
Member Author

👓

@jspahrsummers
Copy link
Member

😎

jspahrsummers added a commit that referenced this pull request Oct 28, 2013
Implement -respondsToSelector: when using -rac_signalForSelector: on KVO'd target
@jspahrsummers jspahrsummers merged commit dc7c22f into master Oct 28, 2013
@jspahrsummers jspahrsummers deleted the kvo-respond-to-selector branch October 28, 2013 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implementing delegate methods outside of RAC
4 participants