MessageThrottle
MessageThrottle copied to clipboard
A lightweight Objective-C message throttle and debounce library.
libobjc.A.dylib _objc_setAssociatedObject + 48 1 BuGeElectricContest -[MTRule deallocObject] (MessageThrottle.m:179) 2 BuGeElectricContest -[MTRule deallocObject] (MessageThrottle.m:179) 3 BuGeElectricContest -[MTRule invokingLastInvocation] (MessageThrottle.m:190) 4 libdispatch.dylib __dispatch_client_callout + 16 13 UIKitCore _UIApplicationMain + 164 14...
我的工程中集成了神策统计,神策在处理统一的点击事件捕获是,使用了和MessageThrottle类似的生成一个形如EditViewController_6_XXXX 虚拟子类的操作,此处的数字会递增,反复进入同一个页面,可能会生成EditViewController_8_XXXX、EditViewController_9_XXXX 这种情况。 在 mt_overrideMethod 这个方法中,[MTEngine.defaultEngine.classHooked addObject:cls]添加的cls实际是神策统计生成的虚拟子类。 由于没有remove的操作,当下一次限流方法再次执行时,下面的代码在进行isSubclassOfClass判断是会发生崩溃,因为classHooked里的存放是EditViewController_8_XXXX,而传入的是EditViewController_9_XXXX。 ``` // check if subclass has hooked! for (Class clsHooked in MTEngine.defaultEngine.classHooked) { if (clsHooked != cls && [clsHooked isSubclassOfClass:cls]) { NSLog(@"Sorry:...
MTPerformModeLast 所存储的lastTimeRequest不应该保存now+rule.durationThreshold的时间吗 不然怎么保证的请求的是最后一次
[[NSDate date] timeIntervalSince1970]会受系统时间影响,用CACurrentMediaTime()比较是不是好一点。 NSTimeInterval machTime = CACurrentMediaTime(), 如果rule.lastMachTime > machTime,就用machTime比较时间间隔。否则就用NSDate比较。像这样: 
崩掉了!
> Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 CoreFoundation 0x0000000183d30bc8 -[__NSCFString getCString:maxLength:encoding:] + 4 1 Foundation 0x00000001847c1584 NSSelectorFromString + 96 2 xxxx 0x0000000102fe1c04 mt_forwardInvocation + 252932 (MessageThrottle.m:823)...
How to use in swift?