网络超时的写法

来源:互联网 发布:Java局部变量作用域 编辑:程序博客网 时间:2024/04/30 03:49

网络超时的写法

by 伍雪颖

NSHTTPURLResponse *response = nil;NSError *error = nil;NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]];request.timeoutInterval = 15;request.HTTPMethod = @"POST";NSData *respData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];if (error) {    NSLog(@"error");    [ZAActivityBar showErrorWithStatus:@"Network unavailabel! Please try again!"];}


1 1
原创粉丝点击