Skip to content

Commit 347af73

Browse files
committed
Update a few Mac deprecated APIs
1 parent d23bc03 commit 347af73

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

React/Base/macOS/RCTPlatformDisplayLink.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#import <CoreVideo/CVDisplayLink.h>
1616
#import <CoreVideo/CVHostTime.h>
1717

18-
#import <libkern/OSAtomic.h>
18+
#import <os/lock.h>
1919

2020
@interface RCTPlatformDisplayLink ()
2121

@@ -30,7 +30,7 @@ @implementation RCTPlatformDisplayLink
3030
__weak id _target;
3131
NSRunLoop *_runLoop;
3232
NSMutableArray<NSRunLoopMode> *_modes;
33-
OSSpinLock _lock; // OS_SPINLOCK_INIT == 0
33+
os_unfair_lock _lock; // OS_UNFAIR_LOCK_INIT == 0
3434
}
3535

3636
+ (RCTPlatformDisplayLink *)displayLinkWithTarget:(id)target selector:(SEL)sel
@@ -47,15 +47,15 @@ static CVReturn RCTPlatformDisplayLinkCallBack(__unused CVDisplayLinkRef display
4747
RCTPlatformDisplayLink *rctDisplayLink = (__bridge RCTPlatformDisplayLink*)displayLinkContext;
4848

4949
// Lock and check for invalidation prior to calling out to the runloop
50-
OSSpinLockLock(&rctDisplayLink->_lock);
50+
os_unfair_lock_lock(&rctDisplayLink->_lock);
5151
if (rctDisplayLink->_runLoop != nil) {
5252
CFRunLoopRef cfRunLoop = [rctDisplayLink->_runLoop getCFRunLoop];
5353
CFRunLoopPerformBlock(cfRunLoop, kCFRunLoopDefaultMode, ^{
5454
[rctDisplayLink tick];
5555
});
5656
CFRunLoopWakeUp(cfRunLoop);
5757
}
58-
OSSpinLockUnlock(&rctDisplayLink->_lock);
58+
os_unfair_lock_unlock(&rctDisplayLink->_lock);
5959
}
6060
return kCVReturnSuccess;
6161
}
@@ -98,10 +98,10 @@ - (void)removeFromRunLoop:(__unused NSRunLoop *)runloop forMode:(NSRunLoopMode)m
9898
- (void)invalidate
9999
{
100100
if (_runLoop != nil) {
101-
OSSpinLockLock(&_lock);
101+
os_unfair_lock_lock(&_lock);
102102
_runLoop = nil;
103103
_modes = nil;
104-
OSSpinLockUnlock(&_lock);
104+
os_unfair_lock_unlock(&_lock);
105105

106106
// CVDisplayLinkStop attempts to acquire a mutex possibly held during the callback's invocation.
107107
// Stop the display link outside of the lock to avoid deadlocking here.

React/Views/RCTActivityIndicatorView.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ - (instancetype)initWithFrame:(CGRect)frame
2323
{
2424
if ((self = [super initWithFrame:frame])) {
2525
self.displayedWhenStopped = NO;
26-
self.style = NSProgressIndicatorSpinningStyle;
26+
self.style = NSProgressIndicatorStyleSpinning;
2727
}
2828
return self;
2929
}
@@ -82,7 +82,7 @@ - (void)updateLayer
8282
[super updateLayer];
8383
if (_color != nil) {
8484
CGFloat r, g, b, a;
85-
[[_color colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&r green:&g blue:&b alpha:&a];
85+
[[_color colorUsingColorSpace:[NSColorSpace genericRGBColorSpace]] getRed:&r green:&g blue:&b alpha:&a];
8686

8787
CIFilter *colorPoly = [CIFilter filterWithName:@"CIColorPolynomial"];
8888
[colorPoly setDefaults];

React/Views/RCTProgressViewManager.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ @implementation RCTConvert (RCTProgressViewManager)
1414

1515
#if TARGET_OS_OSX // [TODO(macOS GH#774)
1616
RCT_ENUM_CONVERTER(NSProgressIndicatorStyle, (@{
17-
@"default": @(NSProgressIndicatorBarStyle),
18-
@"bar": @(NSProgressIndicatorBarStyle),
19-
}), NSProgressIndicatorBarStyle, integerValue)
17+
@"default": @(NSProgressIndicatorStyleBar),
18+
@"bar": @(NSProgressIndicatorStyleBar),
19+
}), NSProgressIndicatorStyleBar, integerValue)
2020
#else // ]TODO(macOS GH#774)
2121
RCT_ENUM_CONVERTER(
2222
UIProgressViewStyle,

React/Views/RCTSlider.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ @implementation RCTSlider {
126126
- (instancetype)initWithFrame:(NSRect)frameRect
127127
{
128128
if (self = [super initWithFrame:frameRect]) {
129-
self.cell.controlSize = NSRegularControlSize;
129+
self.cell.controlSize = NSControlSizeRegular;
130130
((RCTSliderCell*)self.cell).delegate = self;
131131
}
132132
return self;

React/Views/RCTSwitch.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ @implementation RCTSwitch
1919
- (instancetype)initWithFrame:(CGRect)frame
2020
{
2121
if ((self = [super initWithFrame:frame])) {
22-
self.buttonType = NSSwitchButton;
22+
self.buttonType = NSButtonTypeSwitch;
2323
self.title = @""; // default is "Button"
2424
}
2525
return self;
@@ -34,20 +34,20 @@ - (void)setOn:(BOOL)on animated:(BOOL)animated
3434
}
3535
#else // [TODO(macOS GH#774)
3636
- (void)setOn:(BOOL)on animated:(BOOL)animated {
37-
self.state = on ? NSOnState : NSOffState;
37+
self.state = on ? NSControlStateValueOn : NSControlStateValueOff;
3838
}
3939
#endif // ]TODO(macOS GH#774)
4040

4141
#if TARGET_OS_OSX
4242

4343
- (BOOL)on
4444
{
45-
return self.state == NSOnState;
45+
return self.state == NSControlStateValueOn;
4646
}
4747

4848
- (void)setOn:(BOOL)on
4949
{
50-
self.state = on ? NSOnState : NSOffState;
50+
self.state = on ? NSControlStateValueOn : NSControlStateValueOff;
5151
}
5252

5353
#endif // ]TODO(macOS GH#774)

0 commit comments

Comments
 (0)