nsurlsessiontask

How to disable caching from NSURLSessionTask

ぐ巨炮叔叔 提交于 2019-11-28 05:42:31
In my iOS app, I am using NSURLSessionTask to download json data to my app. I discovered that when I call the url directly from the browser, I get an up to date json and when it's called from within the app, I get an older version of the json. Is this due to caching? How can I tell NSURLSessionTask to not use caching. This is the call I use: NSURLSessionTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { Thanks! If your read the links from @runmad you can see in the flow chart that if the HEAD of the file

How do I unit test HTTP request and response using NSURLSession in iOS 7.1?

坚强是说给别人听的谎言 提交于 2019-11-27 10:53:43
问题 I'd like to know how to "unit test" HTTP requests and responses using NSURLSession. Right now, my completion block code does not get called when running as a unit test. However, when the same code is executed from within the AppDelegate (didFinishWithLaunchingOptions), the code inside the completion block is called. As suggested in this thread, NSURLSessionDataTask dataTaskWithURL completion handler not getting called, the use of semaphores and/or dispatch_group is needed "to make sure the

How to disable caching from NSURLSessionTask

戏子无情 提交于 2019-11-27 05:35:11
问题 In my iOS app, I am using NSURLSessionTask to download json data to my app. I discovered that when I call the url directly from the browser, I get an up to date json and when it's called from within the app, I get an older version of the json. Is this due to caching? How can I tell NSURLSessionTask to not use caching. This is the call I use: NSURLSessionTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {