My question is whether I can set some sort of cachePolicy of NSURLMutuableRequest so that the Data is not loaded into the memory.
That depends on how you create your data task. If you use the convenience initialisers (for example,
-dataTaskWithRequest:completionHandler:
), the completion handler is called with an NSData object containing the response body, so that obviously has to be all loaded into memory at that point. OTOH, if you use the standard initialiser (for example,
-dataTaskWithRequest:
), data is passed to you via a delegate callback (
-URLSession:dataTask:didReceiveData:
) and thus does not need to be loaded in memory all at once.
The cache policy shouldn’t really matter in this case. The cache will only accept responses up to a certain size, and your responses are definitely too big to be cached.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"