HTTP链接有很多中方法,在这里介绍一个简单的GET链接,以后不断更新
源码source 如下:
+ (NSData *)Get: (NSString *)url{
NSError *error = nil; //create a error intance
[[NSURLCache sharedURLCache] removeAllCachedResponses];
NSURL *urlURL = [NSURL URLWithString:url];
NSURLRequest *currentUrlRequest = [NSURLRequest requestWithURL:urlURL]; //make a request
NSData *returnData = [NSURLConnection sendSynchronousRequest:currentUrlRequest returningResponse:nil error:&error]; //conncet and get response,there are some another methods which you can study by yourself.
if (error) {
NSLog(@"%@",[error localizedDescription]);
return nil;
}
return returnData;
}
继续连载 下次是文件传输