nsurlsession

what is the delegate of these NSURLSession methods in Swift?

房东的猫 提交于 2019-12-13 22:56:03
问题 XCode is not auto completing this methods i did set the delegate for NSURLSessionTaskDelegate , NSURLSessionDelegate,NSURLSessionDownloadDelegate but it still not completing so i feel that i am setting the wrong delegates cause thats what xcode do when i set the wrong delegate URLSession(_:downloadTask:didResumeAtOffset:expectedTotalBytes:) URLSession(_:downloadTask:didWriteData:totalBytesWritten:totalBytesExpectedToWrite:) URLSession(_:downloadTask:didFinishDownloadingToURL:) well whats

Does not setting cache-control automatically enable caching even without conditional request?

大兔子大兔子 提交于 2019-12-13 21:00:53
问题 For the following image: https://upload.wikimedia.org/wikipedia/commons/7/79/2010-brown-bear.jpg There isn't any cache-control header. And based on here even if you don't send anything then it will use its default value which is private . That being doesn't the URLSession need to perform a conditional request to make sure its still valid? Is there anything in the headers that allows it to make such a conditional request? Because I don't see cache-control , max-age , Expires . The only things

How to update JSON File from web server

偶尔善良 提交于 2019-12-13 18:20:39
问题 I have my local data in json file like : { "locations": [ { "title": "The Pump Room", "place": "Bath", "latitude": 51.38131, "longitude": -2.35959, "information": "The Pump Room Restaurant in Bath is one of the city’s most elegant places to enjoy stylish, Modern-British cuisine.", "telephone": "+44 (0)1225 444477", "visited" : true }, { "title": "The Eye", "place": "London", "latitude": 51.502866, "longitude": -0.119483, "information": "At 135m, the London Eye is the world’s largest

Swift - NSURLSession downloading in background?

老子叫甜甜 提交于 2019-12-13 07:09:39
问题 I'm creating an iOS app by swift that is as same as the AliExpress iOS app. This App has ability that connect to our site and download all of data from JSON api online. Now, I wanna download the images of the icons and banner slider from our site by JSON api in main page. But I don't know how i can do it. Do I use queues or background functions like in android? Also, I'm an android developer and i know how i can do this in android. You can guide me by this way ,too. please guide me by sample

NSURLSessionConfiguration TLSMinimumSupportedProtocol looks like doesn't work on iOS

岁酱吖の 提交于 2019-12-13 07:08:46
问题 From the beginning, how I configure NSURLSession : auto securityPolicy = self.securityPolicy; NSURLSessionConfiguration *config = [NSURLSessionConfiguration ephemeralSessionConfiguration]; config.TLSMinimumSupportedProtocol = [CSHTTPSessionWrapper minimumTLSprotocolForSecurityPolicy: securityPolicy]; // this properly sets values kTLSProtocol1, kTLSProtocol11, kTLSProtocol12 self.session = [NSURLSession sessionWithConfiguration: config delegate: self delegateQueue: nil]; Nothing fancy. Now I

Google Places API web service using swift returns error 303

南笙酒味 提交于 2019-12-13 05:42:59
问题 I am trying to use the Google Places Web Service through iOS (using swift). The reason I want to do so - I want to allow browsing places on a map, even if they are not nearby (the only search allowed using the iOS provided library). I also need to do it programmatically (since in one use-case I want to allow browsing the map, while in another use case - I want the places to be constant and not change based on the map camera). I can't use the iOS place picker, since I want the map to display

How to set URLSession Swift 3

谁都会走 提交于 2019-12-13 04:06:37
问题 Hey having trouble with Swift 3. I have the following code: public var urlSession : URLSession? self.urlSession = URLSession(configuration: URLSessionConfiguration.default, delegate: self, delegateQueue: OperationQueue.main) I am getting the following error message: "URLSession produces (), not the expected contextual result type URLSession?" What am I doing wrong here? 回答1: My I ask your URLSession functions? Maybe problem in your code is like: func URLSession(session: URLSession, dataTask:

Clearing temp download files after Network Failure using NSURLSession

泪湿孤枕 提交于 2019-12-13 00:36:12
问题 I'm using NSURLSession to download a list of files in my app.I have support for background downloading and is working correctly.But some times when the WiFi connectivity is lost while the app is in background,some files remain in the temp directory( com.apple.nsnetworkd ) and is not getting removed.So when i download a new set of files these files still remains in the directory.This situation repeats on WiFi failures and the set of files keeps accumulating.Any way to solve this issue? Will

iOS UrlSession.shared.dataTask removes utf-8 “+” character and replaces it with “ ”

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 21:16:34
问题 I'm creating a login call to an API using x-www-form-endoded data. I created a POST in Postman and received a 200 response. I used Postman's export function to generate the OKHTTP code for Android and NSURL code for iOS. The Android code works fine, but the iOS code receives a 401 response. I used Charles web debugging proxy to look at what was actually being sent for the payload. For android the username is correctly represented as "username=james+jypsee@jypsee.com" but in iOS it comes out

Swift: Parsing JSON Dictionary Values

别等时光非礼了梦想. 提交于 2019-12-12 14:24:52
问题 I'm trying to parse JSON data. What I can do is to save JSON data as an NSData file. Then I can read it as NSDictionary and set some values to respective text fields. What I cannot do is to put those values from JSON directly to respective text fields. The source of the data is Open Weather Map. That's not really important for me. I just need data to practice JSON parsing. Anyway, the following is what I have. @IBOutlet weak var coordField1: UITextField! @IBOutlet weak var countryField1: