From 8be693340c2e5824b1c58a4a18a37ac1ad423431 Mon Sep 17 00:00:00 2001 From: yulingtianxia Date: Thu, 29 Mar 2018 19:49:44 +0800 Subject: [PATCH] 1.1.3 fix bugs --- MessageThrottle.podspec | 2 +- MessageThrottle/MessageThrottle.m | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MessageThrottle.podspec b/MessageThrottle.podspec index a2386f8..8bf5a75 100644 --- a/MessageThrottle.podspec +++ b/MessageThrottle.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "MessageThrottle" -s.version = "1.1.2" +s.version = "1.1.3" s.summary = "A lightweight Objective-C message throttle and debounce library." s.description = <<-DESC MessageThrottle is a lightweight, simple library for controlling frequency of forwarding Objective-C messages. You can choose to control existing methods per instance or per class. It's an implementation of function throttle/debounce developed with Objective-C runtime. diff --git a/MessageThrottle/MessageThrottle.m b/MessageThrottle/MessageThrottle.m index 26c52cc..f1d0c12 100644 --- a/MessageThrottle/MessageThrottle.m +++ b/MessageThrottle/MessageThrottle.m @@ -141,11 +141,11 @@ - (BOOL)applyRule:(MTRule *)rule __block BOOL shouldApply = YES; if (mt_checkRuleValid(rule)) { [self.rules enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, MTRule * _Nonnull obj, BOOL * _Nonnull stop) { - if (sel_isEqual(rule.selector, obj.selector)) { - - Class clsA = mt_classOfTarget(rule.target); - Class clsB = mt_classOfTarget(obj.target); - + if (sel_isEqual(rule.selector, obj.selector) + && mt_object_isClass(rule.target) + && mt_object_isClass(obj.target)) { + Class clsA = rule.target; + Class clsB = obj.target; shouldApply = !([clsA isSubclassOfClass:clsB] || [clsB isSubclassOfClass:clsA]); *stop = shouldApply; NSCAssert(shouldApply, @"Error: %@ already apply rule in %@. A message can only have one rule per class hierarchy.", NSStringFromSelector(obj.selector), NSStringFromClass(clsB));