SORU
4 Aralık 2011, Pazar


Nasıl bir dosya indirme ve belgeleri AFNetworking ile dizine kaydedin.

AFNetworking kitaplığı kullanıyorum. Bir dosya indirme ve belgeleri kaydetmek dizin nasıl olduğunu çözemedim.

CEVAP
4 Aralık 2011, Pazar


NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"..."]];
AFHTTPRequestOperation *operation = [[[AFHTTPRequestOperation alloc] initWithRequest:request] autorelease];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"filename"];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO];

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"Successfully downloaded file to %@", path);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

[operation start];

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Awesome Toys TV

    Awesome Toys

    18 HAZİRAN 2014
  • EminemMusic

    EminemMusic

    9 ŞUBAT 2007
  • pendrop gaming

    pendrop gami

    4 ŞUBAT 2013