Comments (3)
Hm, I see what you mean. Probably the block needs to move the file there.
@mattt, could you have a look at this? If not, I could also update it!
from articles.
- it says in the last: "...the completion handler to move the file from its temporary location to a permanent location, which is then the return value of the block: ". But the block here actually has no return value. so the code below will not be compilable.
Indeed, I had mixed that up with what AFNetworking does for download tasks. The code should be:
NSURLSessionDownloadTask *downloadTask = [session downloadTaskWithRequest:request
completionHandler:
^(NSURL *location, NSURLResponse *response, NSError *error) {
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
NSURL *documentsDirectoryURL = [NSURL fileURLWithPath:documentsPath];
NSURL *documentURL = [documentsDirectoryURL URLByAppendingPathComponent:[response
suggestedFilename]];
[[NSFileManager defaultManager] moveItemAtURL:location
toURL:documentURL
error:nil];
}];
The updated paragraph should omit ", which is then the return value of the block".
- I also don't get the idea of the code of the block below that is using the [response URL] instead of the return value NSURL * location. isn't the latter to be the actual temp file's URL?
location
is a temporary file in a temporary directory. The purpose of this completion handler is to move it to its final directory and filename, which should be derived from the suggestedFilename
of the response.
from articles.
o,o,soga
from articles.
Related Issues (15)
- Outdated Core Data Concurrency Guide HOT 1
- broken links HOT 5
- Data Synchronization Outdated links HOT 1
- http -> https replacement breaks some links
- Where's repo for blog? HOT 1
- Animations Explained
- Reformat authors page HOT 2
- Common Background Practices - CoreData in the background - passing nil as queue parameter
- IP, TCP and HTTP: comments on HN have a number of corrections HOT 1
- Understanding Scroll Views - A Window into the World: Content Size - wrong image HOT 5
- Make ebook HOT 2
- iCloud and CoreData Article: Add section about when to Update UI HOT 4
- Multipeer servicetype
- Wrong Nomad CLI example HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from articles.