0
回答
NSURLConnection同步异步方式下获取status code
华为云4核8G,高性能云服务器,免费试用   

首先说说异步方式下的获取

#pragma mark NSURLConnection Delegate Methods
    - (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response {
         NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;
         int responseStatusCode = [httpResponse statusCode];
    }

再来说说同步方式下的获取

NSHTTPURLResponse* urlResponse = nil;
NSError *error = [[NSError alloc] init];
responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error];

int statusCode = [urlResponse statusCode];
int errorCode = error.code;





原文链接:http://blog.csdn.net/favormm/article/details/7528089
<无标签>
举报
长平狐
发帖于6年前 0回/634阅
顶部