-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Adding missing nullability attributes #3149
Conversation
Thanks for the PR! What is your use case for nil success blocks? |
204 response codes, using a JSON response serializer.
|
@cnoon Didn't you just handle 204's in Alamofire? Anything we should be aware of here? |
Alternatively, we could route empty responses to the |
Yep makes sense. I've verified this with some simple test additions to the Would you be willing to retarget this PR to the 3_0_0 branch, and convert to |
You could also drop these tests into # pragma mark - Rest Interface
- (void)testThatSuccessBlockIsCalledFor200 {
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
[self.manager
GET:@"status/200"
parameters:nil
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
[expectation fulfill];
}
failure:nil];
[self waitForExpectationsWithCommonTimeoutUsingHandler:nil];
}
- (void)testThatFailureBlockIsCalledFor404 {
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
[self.manager
GET:@"status/404"
parameters:nil
success:nil
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nullable error) {
[expectation fulfill];
}];
[self waitForExpectationsWithCommonTimeoutUsingHandler:nil];
}
- (void)testThatResponseObjectIsEmptyFor204 {
__block id urlResponseObject = nil;
XCTestExpectation *expectation = [self expectationWithDescription:@"Request should succeed"];
[self.manager
GET:@"status/204"
parameters:nil
success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
urlResponseObject = responseObject;
[expectation fulfill];
}
failure:nil];
[self waitForExpectationsWithCommonTimeoutUsingHandler:nil];
XCTAssertNil(urlResponseObject);
} |
Done, thanks! Feel free to close this one, unless you'd like me to update it so these changes go to master too? |
I'm going to close this one out and leave out of master. At this point, The 2.x branch is for critical features only. Since this only affects the NSURLSession API's, I'm going to leave it out for now. Thanks again! |
No description provided.