GET 、POST
GET暴露太多,很少用
1.NSURL;
2.NSURLRequest
3.NSURLConnection
4.处理Error or 返回数据
example:
//1.获取 urlstring
NSString * urlString = [NSString stringWithFormat:@"%@",GETurl];
//采用utf-8编码
urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//2.
NSURL * url = [NSURL URLWithString:urlString];
//3.请求数据
//
NSURLRequest * request = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue]completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
self.imageView11.image = [UIImage imageWithData:data];
}];
时间: 2024-10-17 03:12:09