У любого тела есть простое применение на ASIHttpRequest - PullRequest
0 голосов
/ 13 августа 2010

Есть ли у кого-нибудь простое и понятное приложение на ASIHtttpRequest.

1 Ответ

1 голос
/ 13 августа 2010

Это предназначалось для загрузки видео на 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 /Как в использовании

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...