mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-25 21:05:40 +08:00
Convert alloc/init to new to please linter
This commit is contained in:
@@ -50,7 +50,7 @@
|
||||
launchOptions:launchOptions];
|
||||
|
||||
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||
UIViewController *rootViewController = [[UIViewController alloc] init];
|
||||
UIViewController *rootViewController = [UIViewController new];
|
||||
rootViewController.view = rootView;
|
||||
self.window.rootViewController = rootViewController;
|
||||
[self.window makeKeyAndVisible];
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
initialProperties:nil];
|
||||
|
||||
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||
UIViewController *rootViewController = [[UIViewController alloc] init];
|
||||
UIViewController *rootViewController = [UIViewController new];
|
||||
rootViewController.view = rootView;
|
||||
self.window.rootViewController = rootViewController;
|
||||
[self.window makeKeyAndVisible];
|
||||
|
||||
@@ -45,11 +45,11 @@
|
||||
{
|
||||
[super setUp];
|
||||
|
||||
_uiManager = [[RCTUIManager alloc] init];
|
||||
_uiManager = [RCTUIManager new];
|
||||
|
||||
// Register 20 views to use in the tests
|
||||
for (NSInteger i = 1; i <= 20; i++) {
|
||||
UIView *registeredView = [[UIView alloc] init];
|
||||
UIView *registeredView = [UIView new];
|
||||
[registeredView setReactTag:@(i)];
|
||||
_uiManager.viewRegistry[i] = registeredView;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ RCT_EXPORT_METHOD(test:(__unused NSString *)a
|
||||
|
||||
- (void)testModulesAreInvalidated
|
||||
{
|
||||
AllocationTestModule *module = [[AllocationTestModule alloc] init];
|
||||
AllocationTestModule *module = [AllocationTestModule new];
|
||||
@autoreleasepool {
|
||||
RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:nil
|
||||
moduleProvider:^{
|
||||
@@ -113,7 +113,7 @@ RCT_EXPORT_METHOD(test:(__unused NSString *)a
|
||||
{
|
||||
__weak AllocationTestModule *weakModule;
|
||||
@autoreleasepool {
|
||||
AllocationTestModule *module = [[AllocationTestModule alloc] init];
|
||||
AllocationTestModule *module = [AllocationTestModule new];
|
||||
RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:nil
|
||||
moduleProvider:^{
|
||||
return @[module];
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
self.cache = [[RCTCache alloc] init];
|
||||
self.cache = [RCTCache new];
|
||||
self.cache.countLimit = 3;
|
||||
self.cache.totalCostLimit = 100;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
- (void)setUp
|
||||
{
|
||||
[super setUp];
|
||||
_executor = [[RCTContextExecutor alloc] init];
|
||||
_executor = [RCTContextExecutor new];
|
||||
[_executor setUp];
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ static uint64_t _get_time_nanoseconds(void)
|
||||
";
|
||||
|
||||
[_executor executeApplicationScript:script sourceURL:[NSURL URLWithString:@"http://localhost:8081/"] onComplete:^(__unused NSError *error) {
|
||||
NSMutableArray *params = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *params = [NSMutableArray new];
|
||||
id data = @1;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
double samples[runs / frequency];
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
[super setUp];
|
||||
|
||||
_bridge = [OCMockObject mockForClass:[RCTBridge class]];
|
||||
_eventDispatcher = [[RCTEventDispatcher alloc] init];
|
||||
_eventDispatcher = [RCTEventDispatcher new];
|
||||
((id<RCTBridgeModule>)_eventDispatcher).bridge = _bridge;
|
||||
|
||||
_eventName = RCTNormalizeInputEventName(@"sampleEvent");
|
||||
|
||||
@@ -67,7 +67,7 @@ extern BOOL RCTIsGzippedData(NSData *data);
|
||||
@"headers": @{@"Content-Encoding": @"gzip"},
|
||||
};
|
||||
|
||||
RCTNetworking *networker = [[RCTNetworking alloc] init];
|
||||
RCTNetworking *networker = [RCTNetworking new];
|
||||
__block NSURLRequest *request = nil;
|
||||
[networker buildRequest:query completionBlock:^(NSURLRequest *_request) {
|
||||
request = _request;
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
|
||||
- (RCTShadowView *)_shadowViewWithStyle:(void(^)(css_style_t *style))styleBlock
|
||||
{
|
||||
RCTShadowView *shadowView = [[RCTShadowView alloc] init];
|
||||
RCTShadowView *shadowView = [RCTShadowView new];
|
||||
|
||||
css_style_t style = shadowView.cssNode->style;
|
||||
styleBlock(&style);
|
||||
|
||||
@@ -25,13 +25,13 @@
|
||||
|
||||
- (void)testDictionary
|
||||
{
|
||||
id<RCTComponent> myView = [[UIView alloc] init];
|
||||
id<RCTComponent> myView = [UIView new];
|
||||
myView.reactTag = @4;
|
||||
|
||||
id<RCTComponent> myOtherView = [[UIView alloc] init];
|
||||
id<RCTComponent> myOtherView = [UIView new];
|
||||
myOtherView.reactTag = @5;
|
||||
|
||||
RCTSparseArray *registry = [[RCTSparseArray alloc] init];
|
||||
RCTSparseArray *registry = [RCTSparseArray new];
|
||||
XCTAssertNil(registry[@4], @"how did you have a view when none are registered?");
|
||||
XCTAssertNil(registry[@5], @"how did you have a view when none are registered?");
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@
|
||||
{
|
||||
[super setUp];
|
||||
|
||||
_uiManager = [[RCTUIManager alloc] init];
|
||||
_uiManager = [RCTUIManager new];
|
||||
|
||||
// Register 20 views to use in the tests
|
||||
for (NSInteger i = 1; i <= 20; i++) {
|
||||
UIView *registeredView = [[UIView alloc] init];
|
||||
UIView *registeredView = [UIView new];
|
||||
[registeredView setReactTag:@(i)];
|
||||
_uiManager.viewRegistry[i] = registeredView;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ RCT_EXPORT_MODULE()
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_callbacks = [[NSMutableDictionary alloc] init];
|
||||
_callbacks = [NSMutableDictionary new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ RCT_EXPORT_METHOD(showActionSheetWithOptions:(NSDictionary *)options
|
||||
failureCallback:(__unused RCTResponseSenderBlock)failureCallback
|
||||
successCallback:(RCTResponseSenderBlock)successCallback)
|
||||
{
|
||||
UIActionSheet *actionSheet = [[UIActionSheet alloc] init];
|
||||
UIActionSheet *actionSheet = [UIActionSheet new];
|
||||
|
||||
actionSheet.title = options[@"title"];
|
||||
|
||||
|
||||
@@ -115,11 +115,11 @@ RCT_EXPORT_MODULE()
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
|
||||
_locationManager = [[CLLocationManager alloc] init];
|
||||
_locationManager = [CLLocationManager new];
|
||||
_locationManager.distanceFilter = RCT_DEFAULT_LOCATION_ACCURACY;
|
||||
_locationManager.delegate = self;
|
||||
|
||||
_pendingRequests = [[NSMutableArray alloc] init];
|
||||
_pendingRequests = [NSMutableArray new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -231,7 +231,7 @@ RCT_EXPORT_METHOD(getCurrentPosition:(RCTLocationOptions)options
|
||||
}
|
||||
|
||||
// Create request
|
||||
RCTLocationRequest *request = [[RCTLocationRequest alloc] init];
|
||||
RCTLocationRequest *request = [RCTLocationRequest new];
|
||||
request.successBlock = successBlock;
|
||||
request.errorBlock = errorBlock ?: ^(NSArray *args){};
|
||||
request.options = options;
|
||||
|
||||
@@ -94,7 +94,7 @@ RCT_EXPORT_METHOD(getPhotos:(NSDictionary *)params
|
||||
BOOL __block foundAfter = NO;
|
||||
BOOL __block hasNextPage = NO;
|
||||
BOOL __block calledCallback = NO;
|
||||
NSMutableArray *assets = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *assets = [NSMutableArray new];
|
||||
|
||||
[_bridge.assetsLibrary enumerateGroupsWithTypes:groupTypes usingBlock:^(ALAssetsGroup *group, BOOL *stopGroups) {
|
||||
if (group && (groupName == nil || [groupName isEqualToString:[group valueForProperty:ALAssetsGroupPropertyName]])) {
|
||||
|
||||
@@ -30,7 +30,7 @@ RCT_EXPORT_MODULE()
|
||||
static RCTImageDownloader *sharedInstance;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [[RCTImageDownloader alloc] init];
|
||||
sharedInstance = [RCTImageDownloader new];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ static UIImage *RCTScaledImageForAsset(ALAssetRepresentation *representation,
|
||||
- (ALAssetsLibrary *)assetsLibrary
|
||||
{
|
||||
if (!_assetsLibrary) {
|
||||
_assetsLibrary = [[ALAssetsLibrary alloc] init];
|
||||
_assetsLibrary = [ALAssetsLibrary new];
|
||||
}
|
||||
return _assetsLibrary;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ static UIImage *RCTScaledImageForAsset(ALAssetRepresentation *representation,
|
||||
|
||||
PHAsset *asset = [results firstObject];
|
||||
|
||||
PHImageRequestOptions *imageOptions = [[PHImageRequestOptions alloc] init];
|
||||
PHImageRequestOptions *imageOptions = [PHImageRequestOptions new];
|
||||
|
||||
BOOL useMaximumSize = CGSizeEqualToSize(size, CGSizeZero);
|
||||
CGSize targetSize;
|
||||
|
||||
@@ -31,9 +31,9 @@ RCT_EXPORT_MODULE(ImagePickerIOS);
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_pickers = [[NSMutableArray alloc] init];
|
||||
_pickerCallbacks = [[NSMutableArray alloc] init];
|
||||
_pickerCancelCallbacks = [[NSMutableArray alloc] init];
|
||||
_pickers = [NSMutableArray new];
|
||||
_pickerCallbacks = [NSMutableArray new];
|
||||
_pickerCancelCallbacks = [NSMutableArray new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ RCT_EXPORT_METHOD(openCameraDialog:(NSDictionary *)config
|
||||
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
|
||||
UIViewController *rootViewController = keyWindow.rootViewController;
|
||||
|
||||
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
|
||||
UIImagePickerController *imagePicker = [UIImagePickerController new];
|
||||
imagePicker.delegate = self;
|
||||
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
|
||||
|
||||
@@ -78,11 +78,11 @@ RCT_EXPORT_METHOD(openSelectDialog:(NSDictionary *)config
|
||||
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
|
||||
UIViewController *rootViewController = keyWindow.rootViewController;
|
||||
|
||||
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
|
||||
UIImagePickerController *imagePicker = [UIImagePickerController new];
|
||||
imagePicker.delegate = self;
|
||||
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
|
||||
|
||||
NSMutableArray *allowedTypes = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *allowedTypes = [NSMutableArray new];
|
||||
if ([config[@"showImages"] boolValue]) {
|
||||
[allowedTypes addObject:(NSString *)kUTTypeImage];
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ RCT_EXPORT_MODULE()
|
||||
if ((self = [super init])) {
|
||||
|
||||
// TODO: need a way to clear this store
|
||||
_store = [[NSMutableDictionary alloc] init];
|
||||
_store = [NSMutableDictionary new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ RCT_NOT_IMPLEMENTED(-init)
|
||||
{
|
||||
if ([self validateRequestToken:requestToken]) {
|
||||
if (!_data) {
|
||||
_data = [[NSMutableData alloc] init];
|
||||
_data = [NSMutableData new];
|
||||
}
|
||||
[_data appendData:data];
|
||||
if (_incrementalDataBlock) {
|
||||
|
||||
@@ -55,7 +55,7 @@ RCT_EXPORT_MODULE()
|
||||
{
|
||||
// Lazy setup
|
||||
if (!_session && [self isValid]) {
|
||||
NSOperationQueue *callbackQueue = [[NSOperationQueue alloc] init];
|
||||
NSOperationQueue *callbackQueue = [NSOperationQueue new];
|
||||
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
|
||||
_session = [NSURLSession sessionWithConfiguration:configuration
|
||||
delegate:self
|
||||
|
||||
@@ -65,7 +65,7 @@ static NSString *RCTGenerateFormBoundary()
|
||||
|
||||
parts = [formData mutableCopy];
|
||||
_callback = callback;
|
||||
multipartBody = [[NSMutableData alloc] init];
|
||||
multipartBody = [NSMutableData new];
|
||||
boundary = RCTGenerateFormBoundary();
|
||||
|
||||
return [_networker processDataForHTTPQuery:parts[0] callback:^(NSError *error, NSDictionary *result) {
|
||||
@@ -132,7 +132,7 @@ RCT_EXPORT_MODULE()
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_tasksByRequestID = [[NSMutableDictionary alloc] init];
|
||||
_tasksByRequestID = [NSMutableDictionary new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ RCT_EXPORT_MODULE()
|
||||
}
|
||||
NSDictionaryArray *formData = [RCTConvert NSDictionaryArray:query[@"formData"]];
|
||||
if (formData) {
|
||||
RCTHTTPFormDataHelper *formDataHelper = [[RCTHTTPFormDataHelper alloc] init];
|
||||
RCTHTTPFormDataHelper *formDataHelper = [RCTHTTPFormDataHelper new];
|
||||
formDataHelper.networker = self;
|
||||
return [formDataHelper process:formData callback:callback];
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ NSString *const RCTRemoteNotificationsRegistered = @"RemoteNotificationsRegister
|
||||
+ (UILocalNotification *)UILocalNotification:(id)json
|
||||
{
|
||||
NSDictionary *details = [self NSDictionary:json];
|
||||
UILocalNotification *notification = [[UILocalNotification alloc] init];
|
||||
UILocalNotification *notification = [UILocalNotification new];
|
||||
notification.fireDate = [RCTConvert NSDate:details[@"fireDate"]] ?: [NSDate date];
|
||||
notification.alertBody = [RCTConvert NSString:details[@"alertBody"]];
|
||||
return notification;
|
||||
@@ -186,7 +186,7 @@ RCT_EXPORT_METHOD(checkPermissions:(RCTResponseSenderBlock)callback)
|
||||
|
||||
}
|
||||
|
||||
NSMutableDictionary *permissions = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *permissions = [NSMutableDictionary new];
|
||||
permissions[@"alert"] = @((types & UIUserNotificationTypeAlert) > 0);
|
||||
permissions[@"badge"] = @((types & UIUserNotificationTypeBadge) > 0);
|
||||
permissions[@"sound"] = @((types & UIUserNotificationTypeSound) > 0);
|
||||
|
||||
@@ -51,7 +51,7 @@ typedef struct RGBAPixel {
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_testName = [testName copy];
|
||||
_fileManager = [[NSFileManager alloc] init];
|
||||
_fileManager = [NSFileManager new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ RCT_NOT_IMPLEMENTED(-init)
|
||||
testModule.view = rootView;
|
||||
|
||||
UIViewController *vc = [UIApplication sharedApplication].delegate.window.rootViewController;
|
||||
vc.view = [[UIView alloc] init];
|
||||
vc.view = [UIView new];
|
||||
[vc.view addSubview:rootView]; // Add as subview so it doesn't get resized
|
||||
|
||||
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
|
||||
|
||||
@@ -17,7 +17,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (RCTShadowView *)shadowView
|
||||
{
|
||||
return [[RCTShadowRawText alloc] init];
|
||||
return [RCTShadowRawText new];
|
||||
}
|
||||
|
||||
RCT_EXPORT_SHADOW_PROPERTY(text, NSString)
|
||||
|
||||
@@ -111,12 +111,12 @@ static css_dim_t RCTMeasure(void *context, float width)
|
||||
return _cachedTextStorage;
|
||||
}
|
||||
|
||||
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
|
||||
NSLayoutManager *layoutManager = [NSLayoutManager new];
|
||||
|
||||
NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:self.attributedString];
|
||||
[textStorage addLayoutManager:layoutManager];
|
||||
|
||||
NSTextContainer *textContainer = [[NSTextContainer alloc] init];
|
||||
NSTextContainer *textContainer = [NSTextContainer new];
|
||||
textContainer.lineFragmentPadding = 0.0;
|
||||
textContainer.lineBreakMode = _numberOfLines > 0 ? NSLineBreakByTruncatingTail : NSLineBreakByClipping;
|
||||
textContainer.maximumNumberOfLines = _numberOfLines;
|
||||
@@ -183,7 +183,7 @@ static css_dim_t RCTMeasure(void *context, float width)
|
||||
|
||||
_effectiveLetterSpacing = letterSpacing.doubleValue;
|
||||
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
|
||||
NSMutableAttributedString *attributedString = [NSMutableAttributedString new];
|
||||
for (RCTShadowView *child in [self reactSubviews]) {
|
||||
if ([child isKindOfClass:[RCTShadowText class]]) {
|
||||
RCTShadowText *shadowText = (RCTShadowText *)child;
|
||||
@@ -265,7 +265,7 @@ static css_dim_t RCTMeasure(void *context, float width)
|
||||
|
||||
// if we found anything, set it :D
|
||||
if (hasParagraphStyle) {
|
||||
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
|
||||
paragraphStyle.alignment = _textAlign;
|
||||
paragraphStyle.baseWritingDirection = _writingDirection;
|
||||
CGFloat lineHeight = round(_lineHeight * self.fontSizeMultiplier);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if ((self = [super initWithFrame:frame])) {
|
||||
_textStorage = [[NSTextStorage alloc] init];
|
||||
_textStorage = [NSTextStorage new];
|
||||
_reactSubviews = [NSMutableArray array];
|
||||
|
||||
self.isAccessibilityElement = YES;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
[self addTarget:self action:@selector(textFieldBeginEditing) forControlEvents:UIControlEventEditingDidBegin];
|
||||
[self addTarget:self action:@selector(textFieldEndEditing) forControlEvents:UIControlEventEditingDidEnd];
|
||||
[self addTarget:self action:@selector(textFieldSubmitEditing) forControlEvents:UIControlEventEditingDidEndOnExit];
|
||||
_reactSubviews = [[NSMutableArray alloc] init];
|
||||
_reactSubviews = [NSMutableArray new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view
|
||||
{
|
||||
return [[RCTText alloc] init];
|
||||
return [RCTText new];
|
||||
}
|
||||
|
||||
- (RCTShadowView *)shadowView
|
||||
{
|
||||
return [[RCTShadowText alloc] init];
|
||||
return [RCTShadowText new];
|
||||
}
|
||||
|
||||
#pragma mark - Shadow properties
|
||||
|
||||
@@ -297,16 +297,16 @@ RCT_NOT_IMPLEMENTED(-init)
|
||||
|
||||
_delegateDispatchQueue = dispatch_get_main_queue();
|
||||
|
||||
_readBuffer = [[NSMutableData alloc] init];
|
||||
_outputBuffer = [[NSMutableData alloc] init];
|
||||
_readBuffer = [NSMutableData new];
|
||||
_outputBuffer = [NSMutableData new];
|
||||
|
||||
_currentFrameData = [[NSMutableData alloc] init];
|
||||
_currentFrameData = [NSMutableData new];
|
||||
|
||||
_consumers = [[NSMutableArray alloc] init];
|
||||
_consumers = [NSMutableArray new];
|
||||
|
||||
_consumerPool = [[RCTSRIOConsumerPool alloc] init];
|
||||
_consumerPool = [RCTSRIOConsumerPool new];
|
||||
|
||||
_scheduledRunloops = [[NSMutableSet alloc] init];
|
||||
_scheduledRunloops = [NSMutableSet new];
|
||||
|
||||
[self _initializeStreams];
|
||||
|
||||
@@ -506,7 +506,7 @@ RCT_NOT_IMPLEMENTED(-init)
|
||||
|
||||
|
||||
if (_secure) {
|
||||
NSMutableDictionary *SSLOptions = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *SSLOptions = [NSMutableDictionary new];
|
||||
|
||||
[_outputStream setProperty:(__bridge id)kCFStreamSocketSecurityLevelNegotiatedSSL forKey:(__bridge id)kCFStreamPropertySocketSecurityLevel];
|
||||
|
||||
@@ -1478,7 +1478,7 @@ static const size_t RCTSRFrameHeaderOverhead = 32;
|
||||
consumer = [_bufferedConsumers lastObject];
|
||||
[_bufferedConsumers removeLastObject];
|
||||
} else {
|
||||
consumer = [[RCTSRIOConsumer alloc] init];
|
||||
consumer = [RCTSRIOConsumer new];
|
||||
}
|
||||
|
||||
[consumer setupWithScanner:scanner handler:handler bytesNeeded:bytesNeeded readToCurrentFrame:readToCurrentFrame unmaskBytes:unmaskBytes];
|
||||
@@ -1579,7 +1579,7 @@ static NSRunLoop *networkRunLoop = nil;
|
||||
{
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
networkThread = [[_RCTSRRunLoopThread alloc] init];
|
||||
networkThread = [_RCTSRRunLoopThread new];
|
||||
networkThread.name = @"com.squareup.SocketRocket.NetworkThread";
|
||||
[networkThread start];
|
||||
networkRunLoop = networkThread.runLoop;
|
||||
|
||||
@@ -57,8 +57,8 @@ RCT_EXPORT_MODULE()
|
||||
_jsQueue = dispatch_queue_create("com.facebook.React.WebSocketExecutor", DISPATCH_QUEUE_SERIAL);
|
||||
_socket = [[RCTSRWebSocket alloc] initWithURL:_url];
|
||||
_socket.delegate = self;
|
||||
_callbacks = [[RCTSparseArray alloc] init];
|
||||
_injectedObjects = [[NSMutableDictionary alloc] init];
|
||||
_callbacks = [RCTSparseArray new];
|
||||
_injectedObjects = [NSMutableDictionary new];
|
||||
[_socket setDelegateDispatchQueue:_jsQueue];
|
||||
|
||||
NSURL *startDevToolsURL = [NSURL URLWithString:@"/launch-chrome-devtools" relativeToURL:_url];
|
||||
|
||||
@@ -45,7 +45,7 @@ RCT_EXPORT_MODULE()
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_sockets = [[RCTSparseArray alloc] init];
|
||||
_sockets = [RCTSparseArray new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ void RCTPerformBlockWithAssertFunction(void (^block)(void), RCTAssertFunction as
|
||||
NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary;
|
||||
NSMutableArray *functionStack = threadDictionary[RCTAssertFunctionStack];
|
||||
if (!functionStack) {
|
||||
functionStack = [[NSMutableArray alloc] init];
|
||||
functionStack = [NSMutableArray new];
|
||||
threadDictionary[RCTAssertFunctionStack] = functionStack;
|
||||
}
|
||||
[functionStack addObject:assertFunction];
|
||||
|
||||
@@ -89,10 +89,10 @@ id<RCTJavaScriptExecutor> RCTGetLatestExecutor(void)
|
||||
*/
|
||||
_valid = YES;
|
||||
_loading = YES;
|
||||
_moduleDataByID = [[NSMutableArray alloc] init];
|
||||
_frameUpdateObservers = [[NSMutableSet alloc] init];
|
||||
_scheduledCalls = [[NSMutableArray alloc] init];
|
||||
_scheduledCallbacks = [[RCTSparseArray alloc] init];
|
||||
_moduleDataByID = [NSMutableArray new];
|
||||
_frameUpdateObservers = [NSMutableSet new];
|
||||
_scheduledCalls = [NSMutableArray new];
|
||||
_scheduledCallbacks = [RCTSparseArray new];
|
||||
_jsDisplayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(_jsThreadUpdate:)];
|
||||
|
||||
if (RCT_DEV) {
|
||||
@@ -213,7 +213,7 @@ id<RCTJavaScriptExecutor> RCTGetLatestExecutor(void)
|
||||
RCTAssertMainThread();
|
||||
|
||||
// Register passed-in module instances
|
||||
NSMutableDictionary *preregisteredModules = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *preregisteredModules = [NSMutableDictionary new];
|
||||
|
||||
NSArray *extraModules = nil;
|
||||
if (self.delegate) {
|
||||
@@ -229,7 +229,7 @@ id<RCTJavaScriptExecutor> RCTGetLatestExecutor(void)
|
||||
}
|
||||
|
||||
// Instantiate modules
|
||||
_moduleDataByID = [[NSMutableArray alloc] init];
|
||||
_moduleDataByID = [NSMutableArray new];
|
||||
NSMutableDictionary *modulesByName = [preregisteredModules mutableCopy];
|
||||
for (Class moduleClass in RCTGetModuleClasses()) {
|
||||
NSString *moduleName = RCTBridgeModuleNameForClass(moduleClass);
|
||||
@@ -241,7 +241,7 @@ id<RCTJavaScriptExecutor> RCTGetLatestExecutor(void)
|
||||
// Preregistered instances takes precedence, no questions asked
|
||||
if (!preregisteredModules[moduleName]) {
|
||||
// It's OK to have a name collision as long as the second instance is nil
|
||||
RCTAssert([[moduleClass alloc] init] == nil,
|
||||
RCTAssert([moduleClass new] == nil,
|
||||
@"Attempted to register RCTBridgeModule class %@ for the name "
|
||||
"'%@', but name was already registered by class %@", moduleClass,
|
||||
moduleName, [modulesByName[moduleName] class]);
|
||||
@@ -254,7 +254,7 @@ id<RCTJavaScriptExecutor> RCTGetLatestExecutor(void)
|
||||
}
|
||||
} else {
|
||||
// Module name hasn't been used before, so go ahead and instantiate
|
||||
module = [[moduleClass alloc] init];
|
||||
module = [moduleClass new];
|
||||
}
|
||||
if (module) {
|
||||
modulesByName[moduleName] = module;
|
||||
@@ -299,7 +299,7 @@ id<RCTJavaScriptExecutor> RCTGetLatestExecutor(void)
|
||||
|
||||
- (NSString *)moduleConfig
|
||||
{
|
||||
NSMutableDictionary *config = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *config = [NSMutableDictionary new];
|
||||
for (RCTModuleData *moduleData in _moduleDataByID) {
|
||||
config[moduleData.name] = moduleData.config;
|
||||
if ([moduleData.instance conformsToProtocol:@protocol(RCTFrameUpdateObserver)]) {
|
||||
@@ -667,7 +667,7 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
|
||||
}
|
||||
NSMutableOrderedSet *set = [buckets objectForKey:moduleData];
|
||||
if (!set) {
|
||||
set = [[NSMutableOrderedSet alloc] init];
|
||||
set = [NSMutableOrderedSet new];
|
||||
[buckets setObject:set forKey:moduleData];
|
||||
}
|
||||
[set addObject:@(i)];
|
||||
@@ -785,8 +785,8 @@ RCT_NOT_IMPLEMENTED(-initWithBundleURL:(__unused NSURL *)bundleURL
|
||||
)
|
||||
|
||||
if (calls.count > 0) {
|
||||
_scheduledCalls = [[NSMutableArray alloc] init];
|
||||
_scheduledCallbacks = [[RCTSparseArray alloc] init];
|
||||
_scheduledCalls = [NSMutableArray new];
|
||||
_scheduledCallbacks = [RCTSparseArray new];
|
||||
[self _actuallyInvokeAndProcessModule:@"BatchedBridge"
|
||||
method:@"processBatch"
|
||||
arguments:@[[calls valueForKey:@"js_args"]]];
|
||||
|
||||
@@ -57,7 +57,7 @@ void RCTRegisterModule(Class moduleClass)
|
||||
{
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
RCTModuleClasses = [[NSMutableArray alloc] init];
|
||||
RCTModuleClasses = [NSMutableArray new];
|
||||
});
|
||||
|
||||
RCTAssert([moduleClass conformsToProtocol:@protocol(RCTBridgeModule)],
|
||||
|
||||
@@ -57,9 +57,9 @@
|
||||
if ((self = [super init]))
|
||||
{
|
||||
//create storage
|
||||
_cache = [[NSMutableDictionary alloc] init];
|
||||
_entryPool = [[NSMutableArray alloc] init];
|
||||
_lock = [[NSLock alloc] init];
|
||||
_cache = [NSMutableDictionary new];
|
||||
_entryPool = [NSMutableArray new];
|
||||
_lock = [NSLock new];
|
||||
_totalCost = 0;
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
@@ -256,7 +256,7 @@
|
||||
_totalCost += g;
|
||||
RCTCacheEntry *entry = _cache[key];
|
||||
if (!entry) {
|
||||
entry = [[RCTCacheEntry alloc] init];
|
||||
entry = [RCTCacheEntry new];
|
||||
_cache[key] = entry;
|
||||
}
|
||||
entry.object = obj;
|
||||
|
||||
@@ -60,7 +60,7 @@ RCT_CUSTOM_CONVERTER(NSData *, NSData, [json dataUsingEncoding:NSUTF8StringEncod
|
||||
+ (NSIndexSet *)NSIndexSet:(id)json
|
||||
{
|
||||
json = [self NSNumberArray:json];
|
||||
NSMutableIndexSet *indexSet = [[NSMutableIndexSet alloc] init];
|
||||
NSMutableIndexSet *indexSet = [NSMutableIndexSet new];
|
||||
for (NSNumber *number in json) {
|
||||
NSInteger index = number.integerValue;
|
||||
if (RCT_DEBUG && index < 0) {
|
||||
@@ -139,7 +139,7 @@ RCT_CUSTOM_CONVERTER(NSData *, NSData, [json dataUsingEncoding:NSUTF8StringEncod
|
||||
static NSDateFormatter *formatter;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
formatter = [[NSDateFormatter alloc] init];
|
||||
formatter = [NSDateFormatter new];
|
||||
formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ";
|
||||
formatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"];
|
||||
formatter.timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
|
||||
@@ -383,7 +383,7 @@ RCT_CGSTRUCT_CONVERTER(CGAffineTransform, (@[
|
||||
static RCTCache *colorCache = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
colorCache = [[RCTCache alloc] init];
|
||||
colorCache = [RCTCache new];
|
||||
colorCache.countLimit = 128;
|
||||
});
|
||||
UIColor *color = colorCache[json];
|
||||
@@ -702,7 +702,7 @@ RCT_CGSTRUCT_CONVERTER(CGAffineTransform, (@[
|
||||
// but to use +[UIImage imageNamed] - but this method isn't thread safe
|
||||
static NSMutableDictionary *XCAssetMap = nil;
|
||||
if (!XCAssetMap) {
|
||||
XCAssetMap = [[NSMutableDictionary alloc] init];
|
||||
XCAssetMap = [NSMutableDictionary new];
|
||||
}
|
||||
NSNumber *isAsset = XCAssetMap[path];
|
||||
if (!isAsset || isAsset.boolValue) {
|
||||
@@ -986,7 +986,7 @@ RCT_JSON_ARRAY_CONVERTER(NSNumber)
|
||||
// Can't use RCT_ARRAY_CONVERTER due to bridged cast
|
||||
+ (NSArray *)CGColorArray:(id)json
|
||||
{
|
||||
NSMutableArray *colors = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *colors = [NSMutableArray new];
|
||||
for (id value in [self NSArray:json]) {
|
||||
[colors addObject:(__bridge id)[self CGColor:value]];
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ RCT_EXPORT_MODULE()
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_eventQueue = [[NSMutableDictionary alloc] init];
|
||||
_eventQueueLock = [[NSLock alloc] init];
|
||||
_eventQueue = [NSMutableDictionary new];
|
||||
_eventQueueLock = [NSLock new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -176,7 +176,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (void)dispatchEvent:(id<RCTEvent>)event
|
||||
{
|
||||
NSMutableArray *arguments = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *arguments = [NSMutableArray new];
|
||||
|
||||
if (event.viewTag) {
|
||||
[arguments addObject:event.viewTag];
|
||||
@@ -201,7 +201,7 @@ RCT_EXPORT_MODULE()
|
||||
{
|
||||
[_eventQueueLock lock];
|
||||
NSDictionary *eventQueue = _eventQueue;
|
||||
_eventQueue = [[NSMutableDictionary alloc] init];
|
||||
_eventQueue = [NSMutableDictionary new];
|
||||
_paused = YES;
|
||||
[_eventQueueLock unlock];
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
|
||||
- (CAShapeLayer *)createGraph:(UIColor *)color
|
||||
{
|
||||
CGFloat left = _position & RCTFPSGraphPositionLeft ? 0 : _length;
|
||||
CAShapeLayer *graph = [[CAShapeLayer alloc] init];
|
||||
CAShapeLayer *graph = [CAShapeLayer new];
|
||||
graph.frame = CGRectMake(left, 0, 2 * _margin + _length, self.frame.size.height);
|
||||
graph.backgroundColor = [[color colorWithAlphaComponent:.2] CGColor];
|
||||
graph.fillColor = [color CGColor];
|
||||
|
||||
@@ -68,7 +68,7 @@ RCT_NOT_IMPLEMENTED(-init)
|
||||
NSDictionary *errorDetails = RCTJSONParse(rawText, nil);
|
||||
if ([errorDetails isKindOfClass:[NSDictionary class]] &&
|
||||
[errorDetails[@"errors"] isKindOfClass:[NSArray class]]) {
|
||||
NSMutableArray *fakeStack = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *fakeStack = [NSMutableArray new];
|
||||
for (NSDictionary *err in errorDetails[@"errors"]) {
|
||||
[fakeStack addObject: @{
|
||||
@"methodName": err[@"description"] ?: @"",
|
||||
|
||||
@@ -152,7 +152,7 @@ RCT_NOT_IMPLEMENTED(-init)
|
||||
static RCTKeyCommands *sharedInstance;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [[self alloc] init];
|
||||
sharedInstance = [self new];
|
||||
});
|
||||
|
||||
return sharedInstance;
|
||||
@@ -161,7 +161,7 @@ RCT_NOT_IMPLEMENTED(-init)
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_commands = [[NSMutableSet alloc] init];
|
||||
_commands = [NSMutableSet new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ void RCTPerformBlockWithLogFunction(void (^block)(void), RCTLogFunction logFunct
|
||||
NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary;
|
||||
NSMutableArray *functionStack = threadDictionary[RCTLogFunctionStack];
|
||||
if (!functionStack) {
|
||||
functionStack = [[NSMutableArray alloc] init];
|
||||
functionStack = [NSMutableArray new];
|
||||
threadDictionary[RCTLogFunctionStack] = functionStack;
|
||||
}
|
||||
[functionStack addObject:logFunction];
|
||||
@@ -196,12 +196,12 @@ NSString *RCTFormatLog(
|
||||
NSNumber *lineNumber,
|
||||
NSString *message
|
||||
) {
|
||||
NSMutableString *log = [[NSMutableString alloc] init];
|
||||
NSMutableString *log = [NSMutableString new];
|
||||
if (timestamp) {
|
||||
static NSDateFormatter *formatter;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
formatter = [[NSDateFormatter alloc] init];
|
||||
formatter = [NSDateFormatter new];
|
||||
formatter.dateFormat = formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss.SSS ";
|
||||
});
|
||||
[log appendString:[formatter stringFromDate:timestamp]];
|
||||
|
||||
@@ -49,7 +49,7 @@ RCT_NOT_IMPLEMENTED(-init);
|
||||
- (NSArray *)methods
|
||||
{
|
||||
if (!_methods) {
|
||||
NSMutableArray *moduleMethods = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *moduleMethods = [NSMutableArray new];
|
||||
unsigned int methodCount;
|
||||
Method *methods = class_copyMethodList(object_getClass(_moduleClass), &methodCount);
|
||||
|
||||
@@ -77,14 +77,14 @@ RCT_NOT_IMPLEMENTED(-init);
|
||||
|
||||
- (NSDictionary *)config
|
||||
{
|
||||
NSMutableDictionary *config = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *config = [NSMutableDictionary new];
|
||||
config[@"moduleID"] = _moduleID;
|
||||
|
||||
if (_constants) {
|
||||
config[@"constants"] = _constants;
|
||||
}
|
||||
|
||||
NSMutableDictionary *methodconfig = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *methodconfig = [NSMutableDictionary new];
|
||||
[self.methods enumerateObjectsUsingBlock:^(RCTModuleMethod *method, NSUInteger idx, __unused BOOL *stop) {
|
||||
methodconfig[method.JSMethodName] = @{
|
||||
@"methodID": @(idx),
|
||||
|
||||
@@ -32,7 +32,7 @@ RCT_EXPORT_MODULE()
|
||||
- (UIView *)container
|
||||
{
|
||||
if (!_container) {
|
||||
_container = [[UIView alloc] init];
|
||||
_container = [UIView new];
|
||||
_container.backgroundColor = [UIColor colorWithRed:0 green:0 blue:34/255.0 alpha:1];
|
||||
_container.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
|
||||
}
|
||||
|
||||
@@ -216,14 +216,14 @@ void RCTProfileInit(RCTBridge *bridge)
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
_RCTProfileLock = [[NSRecursiveLock alloc] init];
|
||||
_RCTProfileLock = [NSRecursiveLock new];
|
||||
});
|
||||
RCTProfileLock(
|
||||
RCTProfileStartTime = CACurrentMediaTime();
|
||||
RCTProfileOngoingEvents = [[NSMutableDictionary alloc] init];
|
||||
RCTProfileOngoingEvents = [NSMutableDictionary new];
|
||||
RCTProfileInfo = @{
|
||||
RCTProfileTraceEvents: [[NSMutableArray alloc] init],
|
||||
RCTProfileSamples: [[NSMutableArray alloc] init],
|
||||
RCTProfileTraceEvents: [NSMutableArray new],
|
||||
RCTProfileSamples: [NSMutableArray new],
|
||||
};
|
||||
);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
self.backgroundColor = _redColor;
|
||||
self.hidden = YES;
|
||||
|
||||
UIViewController *rootController = [[UIViewController alloc] init];
|
||||
UIViewController *rootController = [UIViewController new];
|
||||
self.rootViewController = rootController;
|
||||
_rootView = rootController.view;
|
||||
_rootView.backgroundColor = [UIColor clearColor];
|
||||
@@ -102,7 +102,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
|
||||
{
|
||||
NSData *stackFrameJSON = [RCTJSONStringify(stackFrame, nil) dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[stackFrameJSON length]];
|
||||
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest new];
|
||||
request.URL = [RCTConvert NSURL:@"http://localhost:8081/open-stack-frame"];
|
||||
request.HTTPMethod = @"POST";
|
||||
request.HTTPBody = stackFrameJSON;
|
||||
@@ -200,7 +200,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
|
||||
cell.detailTextLabel.font = [UIFont fontWithName:@"Menlo-Regular" size:11];
|
||||
cell.detailTextLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
|
||||
cell.backgroundColor = [UIColor clearColor];
|
||||
cell.selectedBackgroundView = [[UIView alloc] init];
|
||||
cell.selectedBackgroundView = [UIView new];
|
||||
cell.selectedBackgroundView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2];
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:(NSCoder *)aDecoder)
|
||||
static RCTRedBox *_sharedInstance;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
_sharedInstance = [[RCTRedBox alloc] init];
|
||||
_sharedInstance = [RCTRedBox new];
|
||||
});
|
||||
return _sharedInstance;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
+ (instancetype)sparseArray
|
||||
{
|
||||
return [[self alloc] init];
|
||||
return [self new];
|
||||
}
|
||||
|
||||
+ (instancetype)sparseArrayWithCapacity:(NSUInteger)capacity
|
||||
|
||||
@@ -48,9 +48,9 @@
|
||||
|
||||
_bridge = bridge;
|
||||
_dispatchedInitialTouches = NO;
|
||||
_nativeTouches = [[NSMutableOrderedSet alloc] init];
|
||||
_reactTouches = [[NSMutableArray alloc] init];
|
||||
_touchViews = [[NSMutableArray alloc] init];
|
||||
_nativeTouches = [NSMutableOrderedSet new];
|
||||
_reactTouches = [NSMutableArray new];
|
||||
_touchViews = [NSMutableArray new];
|
||||
|
||||
// `cancelsTouchesInView` is needed in order to be used as a top level
|
||||
// event delegated recognizer. Otherwise, lower-level components not built
|
||||
@@ -168,7 +168,7 @@ typedef NS_ENUM(NSInteger, RCTTouchEventType) {
|
||||
originatingTime:(__unused CFTimeInterval)originatingTime
|
||||
{
|
||||
// Update touches
|
||||
NSMutableArray *changedIndexes = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *changedIndexes = [NSMutableArray new];
|
||||
for (UITouch *touch in touches) {
|
||||
NSInteger index = [_nativeTouches indexOfObject:touch];
|
||||
if (index == NSNotFound) {
|
||||
|
||||
@@ -142,7 +142,7 @@ static JSValueRef RCTConsoleProfile(JSContextRef context, __unused JSObjectRef o
|
||||
{
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
profiles = [[NSMutableArray alloc] init];
|
||||
profiles = [NSMutableArray new];
|
||||
});
|
||||
|
||||
static int profileCounter = 1;
|
||||
|
||||
@@ -66,10 +66,10 @@ RCT_EXPORT_MODULE()
|
||||
- (void)setUp
|
||||
{
|
||||
if (!_webView) {
|
||||
_webView = [[UIWebView alloc] init];
|
||||
_webView = [UIWebView new];
|
||||
}
|
||||
|
||||
_objectsToInject = [[NSMutableDictionary alloc] init];
|
||||
_objectsToInject = [NSMutableDictionary new];
|
||||
_commentsRegex = [NSRegularExpression regularExpressionWithPattern:@"(^ *?\\/\\/.*?$|\\/\\*\\*[\\s\\S]*?\\*\\/)" options:NSRegularExpressionAnchorsMatchLines error:NULL],
|
||||
_scriptTagsRegex = [NSRegularExpression regularExpressionWithPattern:@"<(\\/?script[^>]*?)>" options:0 error:NULL],
|
||||
_webView.delegate = self;
|
||||
|
||||
@@ -129,7 +129,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
RCT_EXPORT_METHOD(setAccessibilityContentSizeMultipliers:(NSDictionary *)JSMultipliers)
|
||||
{
|
||||
NSMutableDictionary *multipliers = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *multipliers = [NSMutableDictionary new];
|
||||
for (NSString *__nonnull JSCategory in JSMultipliers) {
|
||||
NSNumber *m = JSMultipliers[JSCategory];
|
||||
NSString *UIKitCategory = [self.class UIKitCategoryFromJSCategory:JSCategory];
|
||||
|
||||
@@ -28,9 +28,9 @@ RCT_EXPORT_MODULE()
|
||||
- (instancetype)init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_alerts = [[NSMutableArray alloc] init];
|
||||
_alertCallbacks = [[NSMutableArray alloc] init];
|
||||
_alertButtonKeys = [[NSMutableArray alloc] init];
|
||||
_alerts = [NSMutableArray new];
|
||||
_alertCallbacks = [NSMutableArray new];
|
||||
_alertButtonKeys = [NSMutableArray new];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ RCT_EXPORT_MODULE()
|
||||
RCTDeleteStorageDirectory();
|
||||
}
|
||||
_clearOnInvalidate = NO;
|
||||
_manifest = [[NSMutableDictionary alloc] init];
|
||||
_manifest = [NSMutableDictionary new];
|
||||
_haveSetup = NO;
|
||||
}
|
||||
|
||||
@@ -199,10 +199,10 @@ RCT_EXPORT_MODULE()
|
||||
if (!_haveSetup) {
|
||||
NSDictionary *errorOut;
|
||||
NSString *serialized = RCTReadFile(RCTGetManifestFilePath(), nil, &errorOut);
|
||||
_manifest = serialized ? [RCTJSONParse(serialized, &error) mutableCopy] : [[NSMutableDictionary alloc] init];
|
||||
_manifest = serialized ? [RCTJSONParse(serialized, &error) mutableCopy] : [NSMutableDictionary new];
|
||||
if (error) {
|
||||
RCTLogWarn(@"Failed to parse manifest - creating new one.\n\n%@", error);
|
||||
_manifest = [[NSMutableDictionary alloc] init];
|
||||
_manifest = [NSMutableDictionary new];
|
||||
}
|
||||
_haveSetup = YES;
|
||||
}
|
||||
@@ -377,7 +377,7 @@ RCT_EXPORT_METHOD(multiRemove:(NSArray *)keys
|
||||
|
||||
RCT_EXPORT_METHOD(clear:(RCTResponseSenderBlock)callback)
|
||||
{
|
||||
_manifest = [[NSMutableDictionary alloc] init];
|
||||
_manifest = [NSMutableDictionary new];
|
||||
NSError *error = RCTDeleteStorageDirectory();
|
||||
if (callback) {
|
||||
callback(@[RCTNullIfNil(error)]);
|
||||
|
||||
@@ -125,7 +125,7 @@ RCT_EXPORT_MODULE()
|
||||
object:nil];
|
||||
|
||||
_defaults = [NSUserDefaults standardUserDefaults];
|
||||
_settings = [[NSMutableDictionary alloc] init];
|
||||
_settings = [NSMutableDictionary new];
|
||||
_extraMenuItems = [NSMutableArray array];
|
||||
|
||||
// Delay setup until after Bridge init
|
||||
@@ -331,7 +331,7 @@ RCT_EXPORT_METHOD(show)
|
||||
return;
|
||||
}
|
||||
|
||||
UIActionSheet *actionSheet = [[UIActionSheet alloc] init];
|
||||
UIActionSheet *actionSheet = [UIActionSheet new];
|
||||
actionSheet.title = @"React Native: Development";
|
||||
actionSheet.delegate = self;
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ RCT_EXPORT_MODULE()
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_paused = YES;
|
||||
_timers = [[RCTSparseArray alloc] init];
|
||||
_timers = [RCTSparseArray new];
|
||||
|
||||
for (NSString *name in @[UIApplicationWillResignActiveNotification,
|
||||
UIApplicationDidEnterBackgroundNotification,
|
||||
@@ -134,7 +134,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (void)didUpdateFrame:(__unused RCTFrameUpdate *)update
|
||||
{
|
||||
NSMutableArray *timersToCall = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *timersToCall = [NSMutableArray new];
|
||||
for (RCTTimer *timer in _timers.allObjects) {
|
||||
if ([timer updateFoundNeedsJSUpdate]) {
|
||||
[timersToCall addObject:timer.callbackID];
|
||||
|
||||
@@ -219,16 +219,16 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
||||
|
||||
_shadowQueue = dispatch_queue_create("com.facebook.React.ShadowQueue", DISPATCH_QUEUE_SERIAL);
|
||||
|
||||
_pendingUIBlocksLock = [[NSLock alloc] init];
|
||||
_pendingUIBlocksLock = [NSLock new];
|
||||
|
||||
_shadowViewRegistry = [[RCTSparseArray alloc] init];
|
||||
_viewRegistry = [[RCTSparseArray alloc] init];
|
||||
_shadowViewRegistry = [RCTSparseArray new];
|
||||
_viewRegistry = [RCTSparseArray new];
|
||||
|
||||
// Internal resources
|
||||
_pendingUIBlocks = [[NSMutableArray alloc] init];
|
||||
_rootViewTags = [[NSMutableSet alloc] init];
|
||||
_pendingUIBlocks = [NSMutableArray new];
|
||||
_rootViewTags = [NSMutableSet new];
|
||||
|
||||
_bridgeTransactionListeners = [[NSMutableSet alloc] init];
|
||||
_bridgeTransactionListeners = [NSMutableSet new];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didReceiveNewContentSizeMultiplier)
|
||||
@@ -284,10 +284,10 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
||||
RCTAssert(_bridge == nil, @"Should not re-use same UIIManager instance");
|
||||
|
||||
_bridge = bridge;
|
||||
_shadowViewRegistry = [[RCTSparseArray alloc] init];
|
||||
_shadowViewRegistry = [RCTSparseArray new];
|
||||
|
||||
// Get view managers from bridge
|
||||
NSMutableDictionary *componentDataByName = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *componentDataByName = [NSMutableDictionary new];
|
||||
for (RCTViewManager *manager in _bridge.modules.allValues) {
|
||||
if ([manager isKindOfClass:[RCTViewManager class]]) {
|
||||
RCTComponentData *componentData = [[RCTComponentData alloc] initWithManager:manager];
|
||||
@@ -326,7 +326,7 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
||||
if (!_viewRegistry) {
|
||||
return;
|
||||
}
|
||||
RCTShadowView *shadowView = [[RCTShadowView alloc] init];
|
||||
RCTShadowView *shadowView = [RCTShadowView new];
|
||||
shadowView.reactTag = reactTag;
|
||||
shadowView.frame = frame;
|
||||
shadowView.backgroundColor = rootView.backgroundColor;
|
||||
@@ -479,7 +479,7 @@ extern NSString *RCTBridgeModuleNameForClass(Class cls);
|
||||
// reactSetFrame: has been called. Note that if reactSetFrame: is not called,
|
||||
// these won't be called either, so this is not a suitable place to update
|
||||
// properties that aren't related to layout.
|
||||
NSMutableArray *updateBlocks = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *updateBlocks = [NSMutableArray new];
|
||||
for (RCTShadowView *shadowView in viewsWithNewFrames) {
|
||||
RCTViewManager *manager = [_componentDataByName[shadowView.viewName] manager];
|
||||
RCTViewManagerUIBlock block = [manager uiBlockToAmendWithShadowView:shadowView];
|
||||
@@ -870,7 +870,7 @@ RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)po
|
||||
// processing the pending blocks in another thread.
|
||||
[_pendingUIBlocksLock lock];
|
||||
NSArray *previousPendingUIBlocks = _pendingUIBlocks;
|
||||
_pendingUIBlocks = [[NSMutableArray alloc] init];
|
||||
_pendingUIBlocks = [NSMutableArray new];
|
||||
[_pendingUIBlocksLock unlock];
|
||||
|
||||
// Execute the previously queued UI blocks
|
||||
@@ -1130,7 +1130,7 @@ RCT_EXPORT_METHOD(clearJSResponder)
|
||||
|
||||
- (NSDictionary *)bubblingEventsConfig
|
||||
{
|
||||
NSMutableDictionary *customBubblingEventTypesConfigs = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *customBubblingEventTypesConfigs = [NSMutableDictionary new];
|
||||
for (RCTComponentData *componentData in _componentDataByName.allValues) {
|
||||
RCTViewManager *manager = componentData.manager;
|
||||
if (RCTClassOverridesInstanceMethod([manager class], @selector(customBubblingEventTypes))) {
|
||||
@@ -1160,7 +1160,7 @@ RCT_EXPORT_METHOD(clearJSResponder)
|
||||
|
||||
- (NSDictionary *)directEventsConfig
|
||||
{
|
||||
NSMutableDictionary *customDirectEventTypes = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *customDirectEventTypes = [NSMutableDictionary new];
|
||||
for (RCTComponentData *componentData in _componentDataByName.allValues) {
|
||||
RCTViewManager *manager = componentData.manager;
|
||||
if (RCTClassOverridesInstanceMethod([manager class], @selector(customDirectEventTypes))) {
|
||||
|
||||
@@ -29,7 +29,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view
|
||||
{
|
||||
return [[UIActivityIndicatorView alloc] init];
|
||||
return [UIActivityIndicatorView new];
|
||||
}
|
||||
|
||||
RCT_EXPORT_VIEW_PROPERTY(color, UIColor)
|
||||
|
||||
@@ -48,8 +48,8 @@ typedef void (^RCTPropBlock)(id<RCTComponent> view, id json);
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_manager = manager;
|
||||
_viewPropBlocks = [[NSMutableDictionary alloc] init];
|
||||
_shadowPropBlocks = [[NSMutableDictionary alloc] init];
|
||||
_viewPropBlocks = [NSMutableDictionary new];
|
||||
_shadowPropBlocks = [NSMutableDictionary new];
|
||||
|
||||
_name = RCTBridgeModuleNameForClass([manager class]);
|
||||
RCTAssert(_name.length, @"Invalid moduleName '%@'", _name);
|
||||
@@ -292,7 +292,7 @@ RCT_NOT_IMPLEMENTED(-init)
|
||||
- (NSDictionary *)viewConfig
|
||||
{
|
||||
Class managerClass = [_manager class];
|
||||
NSMutableDictionary *propTypes = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *propTypes = [NSMutableDictionary new];
|
||||
|
||||
unsigned int count = 0;
|
||||
Method *methods = class_copyMethodList(object_getClass(managerClass), &count);
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
json = [self NSDictionary:json];
|
||||
|
||||
// TODO: more shape types
|
||||
MKShape *shape = [[MKPointAnnotation alloc] init];
|
||||
MKShape *shape = [MKPointAnnotation new];
|
||||
shape.coordinate = [self CLLocationCoordinate2D:json];
|
||||
shape.title = [RCTConvert NSString:json[@"title"]];
|
||||
shape.subtitle = [RCTConvert NSString:json[@"subtitle"]];
|
||||
@@ -53,7 +53,7 @@ RCT_ENUM_CONVERTER(MKMapType, (@{
|
||||
+ (RCTPointAnnotation *)RCTPointAnnotation:(id)json
|
||||
{
|
||||
json = [self NSDictionary:json];
|
||||
RCTPointAnnotation *shape = [[RCTPointAnnotation alloc] init];
|
||||
RCTPointAnnotation *shape = [RCTPointAnnotation new];
|
||||
shape.coordinate = [self CLLocationCoordinate2D:json];
|
||||
shape.title = [RCTConvert NSString:json[@"title"]];
|
||||
shape.subtitle = [RCTConvert NSString:json[@"subtitle"]];
|
||||
|
||||
@@ -34,7 +34,7 @@ RCT_EXPORT_MODULE()
|
||||
// while the UIDatePicker is still sending onChange events. To
|
||||
// fix this we should maybe subclass UIDatePicker and make it
|
||||
// be its own event target.
|
||||
UIDatePicker *picker = [[UIDatePicker alloc] init];
|
||||
UIDatePicker *picker = [UIDatePicker new];
|
||||
[picker addTarget:self action:@selector(onChange:)
|
||||
forControlEvents:UIControlEventValueChanged];
|
||||
return picker;
|
||||
@@ -58,7 +58,7 @@ RCT_REMAP_VIEW_PROPERTY(timeZoneOffsetInMinutes, timeZone, NSTimeZone)
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
{
|
||||
UIDatePicker *view = [[UIDatePicker alloc] init];
|
||||
UIDatePicker *view = [UIDatePicker new];
|
||||
return @{
|
||||
@"ComponentHeight": @(view.intrinsicContentSize.height),
|
||||
@"ComponentWidth": @(view.intrinsicContentSize.width),
|
||||
|
||||
@@ -80,7 +80,7 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01;
|
||||
{
|
||||
if (self.showsUserLocation != showsUserLocation) {
|
||||
if (showsUserLocation && !_locationManager) {
|
||||
_locationManager = [[CLLocationManager alloc] init];
|
||||
_locationManager = [CLLocationManager new];
|
||||
if ([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
|
||||
[_locationManager requestWhenInUseAuthorization];
|
||||
}
|
||||
@@ -114,9 +114,9 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01;
|
||||
|
||||
- (void)setAnnotations:(RCTPointAnnotationArray *)annotations
|
||||
{
|
||||
NSMutableArray *newAnnotationIds = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *annotationsToDelete = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *annotationsToAdd = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *newAnnotationIds = [NSMutableArray new];
|
||||
NSMutableArray *annotationsToDelete = [NSMutableArray new];
|
||||
NSMutableArray *annotationsToAdd = [NSMutableArray new];
|
||||
|
||||
for (RCTPointAnnotation *annotation in annotations) {
|
||||
if (![annotation isKindOfClass:[RCTPointAnnotation class]]) {
|
||||
@@ -150,7 +150,7 @@ const CGFloat RCTMapZoomBoundBuffer = 0.01;
|
||||
[self addAnnotations:annotationsToAdd];
|
||||
}
|
||||
|
||||
NSMutableArray *newIds = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *newIds = [NSMutableArray new];
|
||||
for (RCTPointAnnotation *anno in self.annotations) {
|
||||
if ([anno isKindOfClass:[MKUserLocation class]]) {
|
||||
continue;
|
||||
|
||||
@@ -31,7 +31,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view
|
||||
{
|
||||
RCTMap *map = [[RCTMap alloc] init];
|
||||
RCTMap *map = [RCTMap new];
|
||||
map.delegate = self;
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ RCT_NOT_IMPLEMENTED(-initWithCoder:coder)
|
||||
{
|
||||
if ((self = [super initWithFrame:CGRectZero])) {
|
||||
_bridge = bridge;
|
||||
_modalViewController = [[RCTModalHostViewController alloc] init];
|
||||
_modalViewController = [RCTModalHostViewController new];
|
||||
_touchHandler = [[RCTTouchHandler alloc] initWithBridge:bridge];
|
||||
|
||||
__weak RCTModalHostView *weakSelf = self;
|
||||
|
||||
@@ -18,7 +18,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view
|
||||
{
|
||||
return [[RCTNavItem alloc] init];
|
||||
return [RCTNavItem new];
|
||||
}
|
||||
|
||||
RCT_EXPORT_VIEW_PROPERTY(navigationBarHidden, BOOL)
|
||||
|
||||
@@ -27,7 +27,7 @@ RCT_EXPORT_VIEW_PROPERTY(selectedIndex, NSInteger)
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
{
|
||||
UIPickerView *view = [[UIPickerView alloc] init];
|
||||
UIPickerView *view = [UIPickerView new];
|
||||
return @{
|
||||
@"ComponentHeight": @(view.intrinsicContentSize.height),
|
||||
@"ComponentWidth": @(view.intrinsicContentSize.width)
|
||||
|
||||
@@ -26,7 +26,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view
|
||||
{
|
||||
return [[UIProgressView alloc] init];
|
||||
return [UIProgressView new];
|
||||
}
|
||||
|
||||
RCT_EXPORT_VIEW_PROPERTY(progressViewStyle, UIProgressViewStyle)
|
||||
@@ -38,7 +38,7 @@ RCT_EXPORT_VIEW_PROPERTY(trackImage, UIImage)
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
{
|
||||
UIProgressView *view = [[UIProgressView alloc] init];
|
||||
UIProgressView *view = [UIProgressView new];
|
||||
return @{
|
||||
@"ComponentHeight": @(view.intrinsicContentSize.height),
|
||||
};
|
||||
|
||||
@@ -387,7 +387,7 @@ RCT_NOT_IMPLEMENTED(-init)
|
||||
|
||||
_scrollEventThrottle = 0.0;
|
||||
_lastScrollDispatchTime = CACurrentMediaTime();
|
||||
_cachedChildFrames = [[NSMutableArray alloc] init];
|
||||
_cachedChildFrames = [NSMutableArray new];
|
||||
|
||||
[self addSubview:_scrollView];
|
||||
}
|
||||
@@ -582,7 +582,7 @@ RCT_SCROLL_EVENT_HANDLER(scrollViewDidZoom, RCTScrollEventTypeMove)
|
||||
|
||||
- (NSArray *)calculateChildFramesData
|
||||
{
|
||||
NSMutableArray *updatedChildFrames = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *updatedChildFrames = [NSMutableArray new];
|
||||
[[_contentView reactSubviews] enumerateObjectsUsingBlock:
|
||||
^(UIView *subview, NSUInteger idx, __unused BOOL *stop) {
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ RCT_EXPORT_VIEW_PROPERTY(enabled, BOOL)
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
{
|
||||
RCTSegmentedControl *view = [[RCTSegmentedControl alloc] init];
|
||||
RCTSegmentedControl *view = [RCTSegmentedControl new];
|
||||
return @{
|
||||
@"ComponentHeight": @(view.intrinsicContentSize.height),
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view
|
||||
{
|
||||
RCTSlider *slider = [[RCTSlider alloc] init];
|
||||
RCTSlider *slider = [RCTSlider new];
|
||||
[slider addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged];
|
||||
[slider addTarget:self action:@selector(sliderTouchEnd:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[slider addTarget:self action:@selector(sliderTouchEnd:) forControlEvents:UIControlEventTouchUpOutside];
|
||||
|
||||
@@ -20,7 +20,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view
|
||||
{
|
||||
RCTSwitch *switcher = [[RCTSwitch alloc] init];
|
||||
RCTSwitch *switcher = [RCTSwitch new];
|
||||
[switcher addTarget:self
|
||||
action:@selector(onChange:)
|
||||
forControlEvents:UIControlEventValueChanged];
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
if ((self = [super initWithFrame:CGRectZero])) {
|
||||
_eventDispatcher = eventDispatcher;
|
||||
_tabViews = [[NSMutableArray alloc] init];
|
||||
_tabController = [[UITabBarController alloc] init];
|
||||
_tabViews = [NSMutableArray new];
|
||||
_tabController = [UITabBarController new];
|
||||
_tabController.delegate = self;
|
||||
[self addSubview:_tabController.view];
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
- (UITabBarItem *)barItem
|
||||
{
|
||||
if (!_barItem) {
|
||||
_barItem = [[UITabBarItem alloc] init];
|
||||
_barItem = [UITabBarItem new];
|
||||
}
|
||||
return _barItem;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view
|
||||
{
|
||||
return [[RCTTabBarItem alloc] init];
|
||||
return [RCTTabBarItem new];
|
||||
}
|
||||
|
||||
RCT_EXPORT_VIEW_PROPERTY(selected, BOOL);
|
||||
|
||||
@@ -56,12 +56,12 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (UIView *)view
|
||||
{
|
||||
return [[RCTView alloc] init];
|
||||
return [RCTView new];
|
||||
}
|
||||
|
||||
- (RCTShadowView *)shadowView
|
||||
{
|
||||
return [[RCTShadowView alloc] init];
|
||||
return [RCTShadowView new];
|
||||
}
|
||||
|
||||
- (NSArray *)customBubblingEventTypes
|
||||
|
||||
Reference in New Issue
Block a user