aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/ProtoRPC
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-10-19 15:42:39 -0700
committerGravatar Muxi Yan <mxyan@google.com>2018-10-19 15:43:21 -0700
commit422d3296b2d4fb3f8aa0991c2ffa895251ad8e91 (patch)
tree6ebfe78c33a6164ad3330e6926a11adcef375bf5 /src/objective-c/ProtoRPC
parente542e006eb4ffcd0c19488428a3cfe5605bf41e5 (diff)
Annotate Nullability
Diffstat (limited to 'src/objective-c/ProtoRPC')
-rw-r--r--src/objective-c/ProtoRPC/ProtoRPC.h14
-rw-r--r--src/objective-c/ProtoRPC/ProtoRPC.m14
2 files changed, 16 insertions, 12 deletions
diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h
index 34a519bee5..3a7fd58fb1 100644
--- a/src/objective-c/ProtoRPC/ProtoRPC.h
+++ b/src/objective-c/ProtoRPC/ProtoRPC.h
@@ -21,6 +21,8 @@
#import "ProtoMethod.h"
+NS_ASSUME_NONNULL_BEGIN
+
@class GPBMessage;
/** An object can implement this protocol to receive responses from server from a call. */
@@ -29,12 +31,12 @@
@optional
/** Issued when initial metadata is received from the server. */
-- (void)receivedInitialMetadata:(NSDictionary *)initialMetadata;
+- (void)receivedInitialMetadata:(NSDictionary * _Nullable)initialMetadata;
/**
* Issued when a message is received from the server. The message is the deserialized proto object.
*/
-- (void)receivedProtoMessage:(GPBMessage *)message;
+- (void)receivedProtoMessage:(GPBMessage * _Nullable)message;
/**
* Issued when a call finished. If the call finished successfully, \a error is nil and \a
@@ -42,7 +44,7 @@
* is non-nil and contains the corresponding error information, including gRPC error codes and
* error descriptions.
*/
-- (void)closedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error;
+- (void)closedWithTrailingMetadata:(NSDictionary * _Nullable)trailingMetadata error:(NSError * _Nullable)error;
@required
@@ -68,7 +70,7 @@
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
message:(GPBMessage *)message
responseHandler:(id<GRPCProtoResponseHandler>)handler
- callOptions:(GRPCCallOptions *)callOptions
+ callOptions:(GRPCCallOptions * _Nullable)callOptions
responseClass:(Class)responseClass NS_DESIGNATED_INITIALIZER;
/**
@@ -93,7 +95,7 @@
*/
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
responseHandler:(id<GRPCProtoResponseHandler>)handler
- callOptions:(GRPCCallOptions *)callOptions
+ callOptions:(GRPCCallOptions * _Nullable)callOptions
responseClass:(Class)responseClass NS_DESIGNATED_INITIALIZER;
/**
@@ -117,6 +119,8 @@
@end
+NS_ASSUME_NONNULL_END
+
__attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC
: GRPCCall
diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m
index 44e9bfde0a..f6e3298f62 100644
--- a/src/objective-c/ProtoRPC/ProtoRPC.m
+++ b/src/objective-c/ProtoRPC/ProtoRPC.m
@@ -34,7 +34,7 @@
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
message:(GPBMessage *)message
responseHandler:(id<GRPCProtoResponseHandler>)handler
- callOptions:(GRPCCallOptions *)callOptions
+ callOptions:(GRPCCallOptions * _Nullable)callOptions
responseClass:(Class)responseClass {
if ((self = [super init])) {
_call = [[GRPCStreamingProtoCall alloc] initWithRequestOptions:requestOptions
@@ -70,7 +70,7 @@
- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
responseHandler:(id<GRPCProtoResponseHandler>)handler
- callOptions:(GRPCCallOptions *)callOptions
+ callOptions:(GRPCCallOptions * _Nullable)callOptions
responseClass:(Class)responseClass {
if (requestOptions.host.length == 0 || requestOptions.path.length == 0) {
[NSException raise:NSInvalidArgumentException format:@"Neither host nor path can be nil."];
@@ -153,8 +153,8 @@
});
}
-- (void)receivedInitialMetadata:(NSDictionary *)initialMetadata {
- if (_handler) {
+- (void)receivedInitialMetadata:(NSDictionary * _Nullable)initialMetadata {
+ if (_handler && initialMetadata != nil) {
id<GRPCProtoResponseHandler> handler = _handler;
if ([handler respondsToSelector:@selector(initialMetadata:)]) {
dispatch_async(handler.dispatchQueue, ^{
@@ -164,8 +164,8 @@
}
}
-- (void)receivedRawMessage:(NSData *)message {
- if (_handler) {
+- (void)receivedRawMessage:(NSData * _Nullable)message {
+ if (_handler && message != nil) {
id<GRPCProtoResponseHandler> handler = _handler;
NSError *error = nil;
GPBMessage *parsed = [_responseClass parseFromData:message error:&error];
@@ -188,7 +188,7 @@
}
}
-- (void)closedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error {
+- (void)closedWithTrailingMetadata:(NSDictionary * _Nullable)trailingMetadata error:(NSError * _Nullable)error {
if (_handler) {
id<GRPCProtoResponseHandler> handler = _handler;
if ([handler respondsToSelector:@selector(closedWithTrailingMetadata:error:)]) {