From faab914a0879dc5c7970b38d8b2e5198fd7b9df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E8=97=8D=E6=9D=B1?= Date: Fri, 17 Oct 2014 19:22:17 +0800 Subject: [PATCH] Fix issue #61 --- AsyncDisplayKit/ASControlNode.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/AsyncDisplayKit/ASControlNode.m b/AsyncDisplayKit/ASControlNode.m index 4b1fdf161f..77d0275231 100644 --- a/AsyncDisplayKit/ASControlNode.m +++ b/AsyncDisplayKit/ASControlNode.m @@ -210,6 +210,10 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v { NSParameterAssert(action); NSParameterAssert(controlEventMask != 0); + + // Convert nil to [NSNull null] so that it can be used as a key for NSMapTable. + if (!target) + target = [NSNull null]; // Enumerate the events in the mask, adding the target-action pair for each control event included in controlEventMask _ASEnumerateControlEventsIncludedInMaskWithBlock(controlEventMask, ^ @@ -346,7 +350,10 @@ void _ASEnumerateControlEventsIncludedInMaskWithBlock(ASControlNodeEvent mask, v // Hand off to UIApplication to send the action message. // This also handles sending to the first responder is target is nil. - [[UIApplication sharedApplication] sendAction:action to:target from:self forEvent:event]; + if (target == [NSNull null]) + [[UIApplication sharedApplication] sendAction:action to:nil from:self forEvent:event]; + else + [[UIApplication sharedApplication] sendAction:action to:target from:self forEvent:event]; } } });