Skip to content

Commit

Permalink
Replace mach_absolute_time with CACurrentMediaTime (#2830)
Browse files Browse the repository at this point in the history
## Description

Replaces `mach_absolute_time` with `CACurrentMediaTime` which doesn't
need to be specified in the privacy manifest.

## Test plan

Tested on the Example app.
  • Loading branch information
j-piasecki authored Mar 26, 2024
1 parent 6cb12f4 commit c6ee4a4
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions apple/Handlers/RNLongPressHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@

#import <React/RCTConvert.h>

#import <mach/mach_time.h>

@interface RNBetterLongPressGestureRecognizer : UILongPressGestureRecognizer {
uint64_t startTime;
uint64_t previousTime;
CFTimeInterval startTime;
CFTimeInterval previousTime;
}

- (id)initWithGestureHandler:(RNGestureHandler *)gestureHandler;
Expand All @@ -42,7 +40,7 @@ - (id)initWithGestureHandler:(RNGestureHandler *)gestureHandler

- (void)handleGesture:(UIGestureRecognizer *)recognizer
{
previousTime = mach_absolute_time();
previousTime = CACurrentMediaTime();
[_gestureHandler handleGesture:recognizer];
}

Expand All @@ -64,7 +62,7 @@ - (void)touchesBegan:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
[_gestureHandler.pointerTracker touchesBegan:touches withEvent:event];

_initPosition = [self locationInView:self.view];
startTime = mach_absolute_time();
startTime = CACurrentMediaTime();
[_gestureHandler reset];
[self triggerAction];
}
Expand Down Expand Up @@ -109,13 +107,7 @@ - (void)reset

- (NSUInteger)getDuration
{
static mach_timebase_info_data_t sTimebaseInfo;

if (sTimebaseInfo.denom == 0) {
mach_timebase_info(&sTimebaseInfo);
}

return (NSUInteger)(((previousTime - startTime) * sTimebaseInfo.numer / (sTimebaseInfo.denom * 1000000)));
return (previousTime - startTime) * 1000;
}

@end
Expand Down

0 comments on commit c6ee4a4

Please sign in to comment.