From 6cfdd4b88c21f0136f2558ab475f7573ae5a2e1f Mon Sep 17 00:00:00 2001 From: jnpdx Date: Mon, 23 Sep 2019 01:49:06 -0700 Subject: [PATCH] fix(iOS): Xcode issues and warnings (no functionality changes) (#860) * Fix Xcode warnings (enums, whitespace, string literals) * Add nullability notations --- ios/RNCWebView.h | 22 +++++++++++----------- ios/RNCWebView.m | 14 +++++++------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ios/RNCWebView.h b/ios/RNCWebView.h index 90c996a..6043522 100644 --- a/ios/RNCWebView.h +++ b/ios/RNCWebView.h @@ -13,18 +13,18 @@ @protocol RNCWebViewDelegate -- (BOOL)webView:(RNCWebView *)webView - shouldStartLoadForRequest:(NSMutableDictionary *)request - withCallback:(RCTDirectEventBlock)callback; +- (BOOL)webView:(RNCWebView *_Nonnull)webView + shouldStartLoadForRequest:(NSMutableDictionary *_Nonnull)request + withCallback:(RCTDirectEventBlock _Nonnull)callback; @end @interface RNCWebView : RCTView -@property (nonatomic, weak) id delegate; -@property (nonatomic, copy) NSDictionary *source; +@property (nonatomic, weak) id _Nullable delegate; +@property (nonatomic, copy) NSDictionary * _Nullable source; @property (nonatomic, assign) BOOL messagingEnabled; -@property (nonatomic, copy) NSString *injectedJavaScript; +@property (nonatomic, copy) NSString * _Nullable injectedJavaScript; @property (nonatomic, assign) BOOL scrollEnabled; @property (nonatomic, assign) BOOL sharedCookiesEnabled; @property (nonatomic, assign) BOOL pagingEnabled; @@ -42,20 +42,20 @@ @property (nonatomic, assign) BOOL allowsBackForwardNavigationGestures; @property (nonatomic, assign) BOOL incognito; @property (nonatomic, assign) BOOL useSharedProcessPool; -@property (nonatomic, copy) NSString *userAgent; -@property (nonatomic, copy) NSString *applicationNameForUserAgent; +@property (nonatomic, copy) NSString * _Nullable userAgent; +@property (nonatomic, copy) NSString * _Nullable applicationNameForUserAgent; @property (nonatomic, assign) BOOL cacheEnabled; @property (nonatomic, assign) BOOL javaScriptEnabled; @property (nonatomic, assign) BOOL allowsLinkPreview; @property (nonatomic, assign) BOOL showsHorizontalScrollIndicator; @property (nonatomic, assign) BOOL showsVerticalScrollIndicator; @property (nonatomic, assign) BOOL directionalLockEnabled; -@property (nonatomic, copy) NSString *allowingReadAccessToURL; +@property (nonatomic, copy) NSString * _Nullable allowingReadAccessToURL; + (void)setClientAuthenticationCredential:(nullable NSURLCredential*)credential; + (void)setCustomCertificatesForHost:(nullable NSDictionary *)certificates; -- (void)postMessage:(NSString *)message; -- (void)injectJavaScript:(NSString *)script; +- (void)postMessage:(NSString *_Nullable)message; +- (void)injectJavaScript:(NSString *_Nullable)script; - (void)goForward; - (void)goBack; - (void)reload; diff --git a/ios/RNCWebView.m b/ios/RNCWebView.m index 0a5b70b..134c73f 100644 --- a/ios/RNCWebView.m +++ b/ios/RNCWebView.m @@ -286,8 +286,8 @@ static NSDictionary* customCertificatesForHost; } else { _isFullScreenVideoOpen = NO; RCTUnsafeExecuteOnMainQueueSync(^{ - [RCTSharedApplication() setStatusBarHidden:_savedStatusBarHidden animated:YES]; - [RCTSharedApplication() setStatusBarStyle:_savedStatusBarStyle animated:YES]; + [RCTSharedApplication() setStatusBarHidden:self->_savedStatusBarHidden animated:YES]; + [RCTSharedApplication() setStatusBarStyle:self->_savedStatusBarStyle animated:YES]; }); } #pragma clang diagnostic pop @@ -741,8 +741,8 @@ static NSDictionary* customCertificatesForHost; * topViewController */ -(UIViewController *)topViewController{ -   UIViewController *controller = [self topViewControllerWithRootViewController:[self getCurrentWindow].rootViewController]; -   return controller; + UIViewController *controller = [self topViewControllerWithRootViewController:[self getCurrentWindow].rootViewController]; + return controller; } /** @@ -812,7 +812,7 @@ static NSDictionary* customCertificatesForHost; if (![self.delegate webView:self shouldStartLoadForRequest:event withCallback:_onShouldStartLoadWithRequest]) { - decisionHandler(WKNavigationResponsePolicyCancel); + decisionHandler(WKNavigationActionPolicyCancel); return; } } @@ -831,7 +831,7 @@ static NSDictionary* customCertificatesForHost; } // Allow all navigation by default - decisionHandler(WKNavigationResponsePolicyAllow); + decisionHandler(WKNavigationActionPolicyAllow); } /** @@ -918,7 +918,7 @@ static NSDictionary* customCertificatesForHost; callback([NSString stringWithFormat:@"%@", result]); } if (error != nil) { - RCTLogWarn([NSString stringWithFormat:@"Error evaluating injectedJavaScript: This is possibly due to an unsupported return type. Try adding true to the end of your injectedJavaScript string. %@", error]); + RCTLogWarn(@"%@", [NSString stringWithFormat:@"Error evaluating injectedJavaScript: This is possibly due to an unsupported return type. Try adding true to the end of your injectedJavaScript string. %@", error]); } }]; }