是否有任何机构在ASIHttpRequest上有简单的应用

问题描述:

有没有人在ASIHtttpRequest上有一个简单易懂的应用。是否有任何机构在ASIHttpRequest上有简单的应用

这是为了下载Youtube视频

#import "Downloader.h" 
#import "ASIHTTPRequest.h" 


@implementation Downloader 
- (NSProgressIndicator*)startDownloadingUrl:(NSString*)downloadUrl fileName:(NSString*)fileName { 
    NSURL *url = [NSURL URLWithString:downloadUrl]; 
    myProgressIndicator = [[NSProgressIndicator alloc] init]; 
    [myProgressIndicator setMaxValue: 1]; 

    NSString *destinationPath = [[NSString alloc] initWithFormat:@"%@/Downloads/%@.mp4", NSHomeDirectory(), fileName]; 
    NSLog(@"Dest: %@", destinationPath); 

    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; 
    [request setDelegate:self]; 
    [request setDownloadDestinationPath:destinationPath]; 
    [request setDownloadProgressDelegate:myProgressIndicator]; 
    [request startAsynchronous]; 
    NSLog(@"Max: %f, Value: %f, %@", [myProgressIndicator maxValue],[myProgressIndicator doubleValue],[myProgressIndicator description]); 
    return myProgressIndicator; 
} 

- (void)requestFinished:(ASIHTTPRequest *)request { 
    // Use when fetching text data 
    NSLog(@"Download succesful..."); 
    NSLog(@"Max: %f, Value: %f", [myProgressIndicator maxValue],[myProgressIndicator doubleValue]); 
} 

- (void)requestFailed:(ASIHTTPRequest *)request { 
    NSError *error = [request error]; 

    NSLog(@"%@", error); 
} 
@end 

我直接下载的东西保存到一个目的地......

http://allseeing-i.com/ASIHTTPRequest/How-to-use