mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-27 19:25:11 +08:00
NSNumber arguments must now be nonnull
Summary: The bridge implementation on React Android does not currently support boxed numeric/boolean types (the equivalent of NSNumber arguments on iOS), nor does Java support Objective-C's nil messaging system that transparently casts nil to zero, false, etc for primitive types. To avoid platform incompatibilities, we now treat all primitive arguments as non-nullable rather than silently converting NSNull -> nil -> 0/false. We also now enforce that NSNumber * objects must be explicitly marked as `nonnull` (this restriction may be lifted in future if/when Android supports boxed numbers). Other object types are still assumed to be nullable unless specifically annotated with `nonnull`.
This commit is contained in:
@@ -378,7 +378,7 @@ RCT_EXPORT_METHOD(sendRequest:(NSDictionary *)query
|
||||
}];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(cancelRequest:(NSNumber *)requestID)
|
||||
RCT_EXPORT_METHOD(cancelRequest:(nonnull NSNumber *)requestID)
|
||||
{
|
||||
[_tasksByRequestID[requestID] cancel];
|
||||
[_tasksByRequestID removeObjectForKey:requestID];
|
||||
|
||||
@@ -58,7 +58,7 @@ RCT_EXPORT_MODULE()
|
||||
}
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(connect:(NSURL *)URL socketID:(NSNumber *)socketID)
|
||||
RCT_EXPORT_METHOD(connect:(NSURL *)URL socketID:(nonnull NSNumber *)socketID)
|
||||
{
|
||||
RCTSRWebSocket *webSocket = [[RCTSRWebSocket alloc] initWithURL:URL];
|
||||
webSocket.delegate = self;
|
||||
@@ -67,12 +67,12 @@ RCT_EXPORT_METHOD(connect:(NSURL *)URL socketID:(NSNumber *)socketID)
|
||||
[webSocket open];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(send:(NSString *)message socketID:(NSNumber *)socketID)
|
||||
RCT_EXPORT_METHOD(send:(NSString *)message socketID:(nonnull NSNumber *)socketID)
|
||||
{
|
||||
[_sockets[socketID] send:message];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(close:(NSNumber *)socketID)
|
||||
RCT_EXPORT_METHOD(close:(nonnull NSNumber *)socketID)
|
||||
{
|
||||
[_sockets[socketID] close];
|
||||
_sockets[socketID] = nil;
|
||||
|
||||
Reference in New Issue
Block a user