Explorar el Código

Fix GoogleUtilities nullability regressions (#2079)

Paul Beusterien hace 7 años
padre
commit
2cb236c393

+ 1 - 1
GoogleUtilities.podspec

@@ -1,6 +1,6 @@
 Pod::Spec.new do |s|
   s.name             = 'GoogleUtilities'
-  s.version          = '5.3.5'
+  s.version          = '5.3.6'
   s.summary          = 'Google Utilities for iOS (plus community support for macOS and tvOS)'
 
   s.description      = <<-DESC

+ 3 - 1
GoogleUtilities/CHANGELOG.md

@@ -1,9 +1,11 @@
 # Unreleased
 
+# 5.3.6
+- Fix nullability issues. (#2079)
+
 # 5.3.5
 - Fixed an issue where GoogleUtilities would leak non-background URL sessions.
   (#2061)
-
 - Fixed a crash caused due to `NSURLConnection` delegates being wrapped in an
   `NSProxy`. (#1936)
 

+ 4 - 4
GoogleUtilities/Network/GULNetworkURLSession.m

@@ -102,8 +102,8 @@
 
 /// Sends an async POST request using NSURLSession for iOS >= 7.0, and returns an ID of the
 /// connection.
-- (NSString *)sessionIDFromAsyncPOSTRequest:(NSURLRequest *)request
-                          completionHandler:(GULNetworkURLSessionCompletionHandler)handler
+- (nullable NSString *)sessionIDFromAsyncPOSTRequest:(NSURLRequest *)request
+                                   completionHandler:(GULNetworkURLSessionCompletionHandler)handler
     API_AVAILABLE(ios(7.0)) {
   // NSURLSessionUploadTask does not work with NSData in the background.
   // To avoid this issue, write the data to a temporary file to upload it.
@@ -180,8 +180,8 @@
 }
 
 /// Sends an async GET request using NSURLSession for iOS >= 7.0, and returns an ID of the session.
-- (NSString *)sessionIDFromAsyncGETRequest:(NSURLRequest *)request
-                         completionHandler:(GULNetworkURLSessionCompletionHandler)handler
+- (nullable NSString *)sessionIDFromAsyncGETRequest:(NSURLRequest *)request
+                                  completionHandler:(GULNetworkURLSessionCompletionHandler)handler
     API_AVAILABLE(ios(7.0)) {
   if (_backgroundNetworkEnabled) {
     _sessionConfig = [self backgroundSessionConfigWithSessionID:_sessionID];

+ 15 - 12
GoogleUtilities/Network/Private/GULNetworkURLSession.h

@@ -18,13 +18,15 @@
 
 #import "GULNetworkLoggerProtocol.h"
 
-typedef void (^GULNetworkCompletionHandler)(NSHTTPURLResponse *response,
-                                            NSData *data,
-                                            NSError *error);
-typedef void (^GULNetworkURLSessionCompletionHandler)(NSHTTPURLResponse *response,
-                                                      NSData *data,
+NS_ASSUME_NONNULL_BEGIN
+
+typedef void (^GULNetworkCompletionHandler)(NSHTTPURLResponse *_Nullable response,
+                                            NSData *_Nullable data,
+                                            NSError *_Nullable error);
+typedef void (^GULNetworkURLSessionCompletionHandler)(NSHTTPURLResponse *_Nullable response,
+                                                      NSData *_Nullable data,
                                                       NSString *sessionID,
-                                                      NSError *error);
+                                                      NSError *_Nullable error);
 typedef void (^GULNetworkSystemCompletionHandler)(void);
 
 /// The protocol that uses NSURLSession for iOS >= 7.0 to handle requests and responses.
@@ -41,19 +43,20 @@ typedef void (^GULNetworkSystemCompletionHandler)(void);
                             completionHandler:(GULNetworkSystemCompletionHandler)completionHandler;
 
 /// Initializes with logger delegate.
-- (instancetype)initWithNetworkLoggerDelegate:(id<GULNetworkLoggerDelegate>)networkLoggerDelegate
-    NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithNetworkLoggerDelegate:
+    (nullable id<GULNetworkLoggerDelegate>)networkLoggerDelegate NS_DESIGNATED_INITIALIZER;
 
 - (instancetype)init NS_UNAVAILABLE;
 
 /// Sends an asynchronous POST request and calls the provided completion handler when the request
 /// completes or when errors occur, and returns an ID of the session/connection.
-- (NSString *)sessionIDFromAsyncPOSTRequest:(NSURLRequest *)request
-                          completionHandler:(GULNetworkURLSessionCompletionHandler)handler;
+- (nullable NSString *)sessionIDFromAsyncPOSTRequest:(NSURLRequest *)request
+                                   completionHandler:(GULNetworkURLSessionCompletionHandler)handler;
 
 /// Sends an asynchronous GET request and calls the provided completion handler when the request
 /// completes or when errors occur, and returns an ID of the session.
-- (NSString *)sessionIDFromAsyncGETRequest:(NSURLRequest *)request
-                         completionHandler:(GULNetworkURLSessionCompletionHandler)handler;
+- (nullable NSString *)sessionIDFromAsyncGETRequest:(NSURLRequest *)request
+                                  completionHandler:(GULNetworkURLSessionCompletionHandler)handler;
 
+NS_ASSUME_NONNULL_END
 @end