We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
当viewController死亡后,CTAPIBaseManager的dealloc并没有如期调用,需要等到请求完毕时,才会调用。 下面代码的闭包对CTAPIBaseManager对象进行了强引用,所以没有如期死亡。这也跟旧框架RTNetworking代码不同,现在是这样设计的吗?
CTNetworking代码: NSNumber *requestId = [[CTApiProxy sharedInstance] callApiWithRequest:request success:^(CTURLResponse *response) { [self successedOnCallingAPI:response]; } fail:^(CTURLResponse *response) { CTAPIManagerErrorType errorType = CTAPIManagerErrorTypeDefault; if (response.status == CTURLResponseStatusErrorCancel) { errorType = CTAPIManagerErrorTypeCanceled; } if (response.status == CTURLResponseStatusErrorTimeout) { errorType = CTAPIManagerErrorTypeTimeout; } if (response.status == CTURLResponseStatusErrorNoNetwork) { errorType = CTAPIManagerErrorTypeNoNetWork; } [self failedOnCallingAPI:response withErrorType:errorType]; }];
RTNetworking代码: #define AXCallAPI(REQUEST_METHOD, REQUEST_ID) { __weak typeof(self) weakSelf = self; REQUEST_ID = [[CTApiProxy sharedInstance] call##REQUEST_METHOD##WithParams:apiParams serviceIdentifier:self.child.serviceType methodName:self.child.methodName success:^(CTURLResponse *response) { __strong typeof(weakSelf) strongSelf = weakSelf; [strongSelf successedOnCallingAPI:response]; } fail:^(CTURLResponse *response) { __strong typeof(weakSelf) strongSelf = weakSelf; [strongSelf failedOnCallingAPI:response withErrorType:CTAPIManagerErrorTypeDefault]; }]; [self.requestIdList addObject:@(REQUEST_ID)]; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
当viewController死亡后,CTAPIBaseManager的dealloc并没有如期调用,需要等到请求完毕时,才会调用。
下面代码的闭包对CTAPIBaseManager对象进行了强引用,所以没有如期死亡。这也跟旧框架RTNetworking代码不同,现在是这样设计的吗?
CTNetworking代码:
NSNumber *requestId = [[CTApiProxy sharedInstance] callApiWithRequest:request success:^(CTURLResponse *response) {
[self successedOnCallingAPI:response];
} fail:^(CTURLResponse *response) {
CTAPIManagerErrorType errorType = CTAPIManagerErrorTypeDefault;
if (response.status == CTURLResponseStatusErrorCancel) {
errorType = CTAPIManagerErrorTypeCanceled;
}
if (response.status == CTURLResponseStatusErrorTimeout) {
errorType = CTAPIManagerErrorTypeTimeout;
}
if (response.status == CTURLResponseStatusErrorNoNetwork) {
errorType = CTAPIManagerErrorTypeNoNetWork;
}
[self failedOnCallingAPI:response withErrorType:errorType];
}];
RTNetworking代码:
#define AXCallAPI(REQUEST_METHOD, REQUEST_ID)
{
__weak typeof(self) weakSelf = self;
REQUEST_ID = [[CTApiProxy sharedInstance] call##REQUEST_METHOD##WithParams:apiParams serviceIdentifier:self.child.serviceType methodName:self.child.methodName success:^(CTURLResponse *response) {
__strong typeof(weakSelf) strongSelf = weakSelf;
[strongSelf successedOnCallingAPI:response];
} fail:^(CTURLResponse *response) {
__strong typeof(weakSelf) strongSelf = weakSelf;
[strongSelf failedOnCallingAPI:response withErrorType:CTAPIManagerErrorTypeDefault];
}];
[self.requestIdList addObject:@(REQUEST_ID)];
}
The text was updated successfully, but these errors were encountered: