我是菜鸟NSURLConnection
。我搜索了谷歌并找到了这个网站,但我不明白。
我的朋友请解释我从文档文件夹中的 url 下载的代码。
这是我的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *url =[NSURL URLWithString:@"http://cdn.arstechnica.net/wp-content/uploads/2012/09/iphone5-intro.jpg"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSURLConnection *con = [[NSURLConnection alloc]initWithRequest:request delegate:self];
[con start];}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
//I dont know what thing put here
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)theData
{
//I dont know what thing put here
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
//I dont know what thing put here
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
UIAlertView *errorView = [[UIAlertView alloc]initWithTitle:@"Error" message:@"The Connection has been LOST" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[errorView show];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}