Skip to content

Commit

Permalink
Fix Warnings in Xcode (facebook#23184)
Browse files Browse the repository at this point in the history
Summary:
His PR is related to facebook#22609

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

[IOS][Changed] - Fix warning in RCTImage
[IOS][Changed] - Fix warning in RCTNetwork
Pull Request resolved: facebook#23184

Differential Revision: D13838680

Pulled By: cpojer

fbshipit-source-id: 698303e44bb85a4819abff7d71e0b75936c09dc8
  • Loading branch information
rafaellincoln authored and facebook-github-bot committed Jan 28, 2019
1 parent 5ed1084 commit 79c1be8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
26 changes: 14 additions & 12 deletions Libraries/Image/RCTImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ @implementation RCTImageCache

- (instancetype)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];
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];
}

return self;
}
Expand Down
17 changes: 11 additions & 6 deletions moved/RCTNetInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -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}];
}
}

Expand Down

0 comments on commit 79c1be8

Please sign in to comment.