-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor features (NSNetService and nullability fixes) #674
Conversation
@chrisballinger @jakebromberg @jdeff @zhouzhongguang as you've all committed to this project recently, perhaps you'd care to review this too? |
@@ -656,7 +662,7 @@ typedef NS_ENUM(NSInteger, GCDAsyncSocketError) { | |||
* completes writing the bytes (which is NOT immediately after this method returns, but rather at a later time | |||
* when the delegate method notifies you), then you should first copy the bytes, and pass the copy to this method. | |||
**/ | |||
- (void)writeData:(NSData *)data withTimeout:(NSTimeInterval)timeout tag:(long)tag; | |||
- (void)writeData:(nullable NSData *)data withTimeout:(NSTimeInterval)timeout tag:(long)tag; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When would it be valid to pass nil data here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made it nullable to conform to the docs, line 651: "If you pass in nil or zero-length data, this method does nothing and the delegate will not be called." There could be code out there relying on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with reverting it to nonnull and changing the docs if you'd prefer...
readDataToData: and writeData: are documented to accept nil data and indeed behave as documented, therefore make the parameter nullable as some users may already rely on this behaviour.
NSURL path can return nil, but fileExistsAtPath: can't accept nil, so the compiler was warning, even though this would never likely happen in practice. Added nil check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thank you!
These changes are not as trivial as my last PR, but still pretty straightforward.