Skip to content

Commit 00f18af

Browse files
committed
Fix 多平台编译问题
1 parent c9f2e02 commit 00f18af

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

MessageThrottle/MessageThrottle.m

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@
2323

2424
static inline BOOL mt_object_isClass(id _Nullable obj)
2525
{
26-
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0 || __TV_OS_VERSION_MIN_REQUIRED >= __TVOS_9_0 || __WATCH_OS_VERSION_MIN_REQUIRED >= __WATCHOS_2_0 || __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10
27-
return object_isClass(obj);
28-
#else
2926
if (!obj) return NO;
30-
return obj == [obj class];
31-
#endif
27+
if (@available(iOS 8.0, macOS 10.10, tvOS 9.0, watchOS 2.0, *)) {
28+
return object_isClass(obj);
29+
}
30+
else {
31+
return obj == [obj class];
32+
}
3233
}
3334

3435
Class mt_metaClass(Class cls)
@@ -598,7 +599,12 @@ static void mt_handleInvocation(NSInvocation *invocation, MTRule *rule)
598599
return;
599600
}
600601

602+
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_OSX
601603
NSTimeInterval now = CACurrentMediaTime();
604+
#else
605+
NSTimeInterval now = [[NSDate date] timeIntervalSince1970];
606+
#endif
607+
602608
switch (rule.mode) {
603609
case MTPerformModeFirstly: {
604610
if (now - rule.lastTimeRequest > rule.durationThreshold) {

0 commit comments

Comments
 (0)