简体   繁体   中英

How can i download nsdata to memory with AFNetworking

i enjoy working with AFNetworking 2.0 and i'm stuck on how i can download a file to memory. So far i only know how i can download it to a filepath.

An example without afnetworking would be the synchronous call,

NSData * data = [NSData dataWithContentsOfURL:someurl];

Thanks!

This is asynchronous call:

NSURLRequest *request = [NSURLRequest requestWithURL:someURL];
[NSURLConnection sendAsynchronousRequest:request
                                   queue:[NSOperationQueue mainQueue] 
                       completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
    // You have it.
}

Don't use AFNetworking if you can't do this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM