nsurlsessionconfiguration

How to cache using NSURLSession and NSURLCache. Not working

巧了我就是萌 提交于 2019-11-28 04:09:42
I have a test app setup and it successfully downloads content from the network even if the user switches apps while a download is in progress. Great, now I have background downloads in place. Now I want to add caching. There is no point to me downloading images more than once, b/c of system design, given an image URL I can tell you the content behind that URL will never change. So, now I want to cache the results of my download using apple's built in in-memory/on-disk cache that I've read so much about (as opposed to me saving the file manually in NSCachesDirectory and then checking there

Prevent NSURLSession from caching responses

冷暖自知 提交于 2019-11-27 14:45:34
问题 Why does it cache responses. It returns previously fetched responses. It even works if turning off the network connection. Resetting the iOS simulator did not seem to work either. Making a request, then again with internet offline does work (cached). public let urlSession: NSURLSession public init() { // ... var configuration = NSURLSessionConfiguration.defaultSessionConfiguration() configuration.requestCachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalCacheData urlSession =

Showing the file download progress with NSURLSessionDataTask

只愿长相守 提交于 2019-11-27 12:24:16
I want to display file download progress (how many bytes are received) of particular file. It works fine with the NSURLSessionDownloadTask .My question is I want to achieve the same with the NSURLSessionDataTask. Here is the code which receives file into NSData and writes to document folder: NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: self delegateQueue: [NSOperationQueue mainQueue]]; NSURLSessionDataTask * dataTask = [defaultSession

How to programmatically add a proxy to an NSURLSession

怎甘沉沦 提交于 2019-11-27 07:20:19
Looking over the documentation of NSURLSession and NSURLSessionConfiguration , I was under the impression I should configure it with a dictionary like the following: // Create a dictionary to describe the proxy NSDictionary *proxyDict = @{ (NSString *)kCFProxyHostNameKey : @"myProxyHost.com", (NSString *)kCFProxyPortNumberKey : @"12345", (NSString *)kCFProxyTypeKey : (NSString*)kCFProxyTypeHTTP }; // Create a configuration that uses the dictionary NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; [configuration setConnectionProxyDictionary

How to cache using NSURLSession and NSURLCache. Not working

五迷三道 提交于 2019-11-27 05:17:41
问题 I have a test app setup and it successfully downloads content from the network even if the user switches apps while a download is in progress. Great, now I have background downloads in place. Now I want to add caching. There is no point to me downloading images more than once, b/c of system design, given an image URL I can tell you the content behind that URL will never change. So, now I want to cache the results of my download using apple's built in in-memory/on-disk cache that I've read so

Showing the file download progress with NSURLSessionDataTask

ぐ巨炮叔叔 提交于 2019-11-26 18:11:38
问题 I want to display file download progress (how many bytes are received) of particular file. It works fine with the NSURLSessionDownloadTask .My question is I want to achieve the same with the NSURLSessionDataTask. Here is the code which receives file into NSData and writes to document folder: NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject

NSURLSession concurrent requests with Alamofire

和自甴很熟 提交于 2019-11-26 08:51:48
问题 I\'m experiencing some strange behaviour with my test app. I\'ve about 50 simultaneous GET requests that I send to the same server. The server is an embedded server on a small piece of hardware with very limited resources. In order to optimize the performance for each single request, I configure one instance of Alamofire.Manager as follows: let configuration = NSURLSessionConfiguration.defaultSessionConfiguration() configuration.HTTPMaximumConnectionsPerHost = 2 configuration