Fix Warnings in Xcode (#23184)

Summary:
His PR is related to #22609

Changelog:
----------

[IOS][Changed] - Fix warning in RCTImage
[IOS][Changed] - Fix warning in RCTNetwork
Pull Request resolved: https://github.com/facebook/react-native/pull/23184

Differential Revision: D13838680

Pulled By: cpojer

fbshipit-source-id: 698303e44bb85a4819abff7d71e0b75936c09dc8
This commit is contained in:
Rafael Lincoln 2019-01-28 03:54:53 -08:00 committed by Facebook Github Bot
parent d0cd3cae13
commit 5a87093e1a
2 changed files with 24 additions and 17 deletions

View File

@ -36,18 +36,20 @@ static NSString *RCTCacheKeyForImage(NSString *imageTag, CGSize size, CGFloat sc
- (instancetype)init
{
_decodedImageCache = [NSCache new];
_decodedImageCache.totalCostLimit = 20 * 1024 * 1024; // 20 MB
_cacheStaleTimes = [[NSMutableDictionary alloc] init];
if (self = [super init]) {
_decodedImageCache = [NSCache new];
_decodedImageCache.totalCostLimit = 20 * 1024 * 1024; // 20 MB
_cacheStaleTimes = [[NSMutableDictionary alloc] init];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(clearCache)
name:UIApplicationDidReceiveMemoryWarningNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(clearCache)
name:UIApplicationWillResignActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(clearCache)
name:UIApplicationDidReceiveMemoryWarningNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(clearCache)
name:UIApplicationWillResignActiveNotification
object:nil];
}
return self;
}

View File

@ -52,20 +52,25 @@ static void RCTReachabilityCallback(__unused SCNetworkReachabilityRef target, SC
{
RCTNetInfo *self = (__bridge id)info;
BOOL didSetReachabilityFlags = [self setReachabilityStatus:flags];
NSString *connectionType = self->_connectionType ?: RCTConnectionTypeUnknown;
NSString *effectiveConnectionType = self->_effectiveConnectionType ?: RCTEffectiveConnectionTypeUnknown;
NSString *networkInfo = self->_statusDeprecated ?: RCTReachabilityStateUnknown;
if (self->_firstTimeReachability && self->_resolve) {
SCNetworkReachabilityUnscheduleFromRunLoop(self->_firstTimeReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
CFRelease(self->_firstTimeReachability);
self->_resolve(@{@"connectionType": self->_connectionType ?: RCTConnectionTypeUnknown,
@"effectiveConnectionType": self->_effectiveConnectionType ?: RCTEffectiveConnectionTypeUnknown,
@"network_info": self->_statusDeprecated ?: RCTReachabilityStateUnknown});
self->_resolve(@{@"connectionType": connectionType,
@"effectiveConnectionType": effectiveConnectionType,
@"network_info": networkInfo});
self->_firstTimeReachability = nil;
self->_resolve = nil;
}
if (didSetReachabilityFlags && self->_isObserving) {
[self sendEventWithName:@"networkStatusDidChange" body:@{@"connectionType": self->_connectionType,
@"effectiveConnectionType": self->_effectiveConnectionType,
@"network_info": self->_statusDeprecated}];
[self sendEventWithName:@"networkStatusDidChange" body:@{@"connectionType": connectionType,
@"effectiveConnectionType": effectiveConnectionType,
@"network_info": networkInfo}];
}
}