私は初心者ですNSURLConnection
。Google で検索してこのサイトを見つけましたが、よくわかりません。
私の友人は、Document フォルダの 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;
}