nsurlsession

nsurlsession for multiple request in loop

北慕城南 提交于 2020-01-05 08:42:09
问题 I have been trying to download image/txt but i need to do it until that url exists & download that image/txt file,so i keep calling same method again & when i set debug point i see this . If url is right than i do not see any queue in debug navigator because it is not calling method again. i referred AFNetworking library to the same but i guess it`s working in same way as i am doing in NSURLSession,right? Case:- I check for url if exists or not, so if it`s exists than load both urls(time.txt

nsurlsession for multiple request in loop

我怕爱的太早我们不能终老 提交于 2020-01-05 08:41:57
问题 I have been trying to download image/txt but i need to do it until that url exists & download that image/txt file,so i keep calling same method again & when i set debug point i see this . If url is right than i do not see any queue in debug navigator because it is not calling method again. i referred AFNetworking library to the same but i guess it`s working in same way as i am doing in NSURLSession,right? Case:- I check for url if exists or not, so if it`s exists than load both urls(time.txt

Preventing NSURLSession default HTTP headers

狂风中的少年 提交于 2020-01-05 07:44:18
问题 I'm trying to craft a very specific HTTP request to a server (ie. defining the exact set of HTTP headers), but NSURLSession keeps "helpfully" inserting a bunch of HTTP headers like Accept , Accept-Language and Accept-Encoding . Consider the following playground (Swift 2.x) which sends a request to a service that just echos the HTTP headers that were sent: import Foundation import XCPlayground XCPlaygroundPage.currentPage.needsIndefiniteExecution = true let url = NSURL(string: "http://httpbin

Can't resolve “Ambiguous use of subscript”

末鹿安然 提交于 2020-01-05 04:02:32
问题 I'm trying to convert a JSON response (from an NSUrlSession ) into an array that I can use. It's weird, this was working last night. However I now have a build error saying "ambiguous use of subscript". let url = NSURL(string: "http://192.168.0.8/classes/main.php?fn=dogBoardingGet") let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {(data, response, error) in print(NSString(data: data!, encoding: NSUTF8StringEncoding)) //var boardings = [String]() do { let json = try

How to aggregate response from multiple NSURLSessionDataTasks?

依然范特西╮ 提交于 2020-01-05 03:11:20
问题 I am trying to aggregate the data from multiple NSURLSessionDataTasks that will run concurrently. __block NSMutableDictionary *languageDetails = [NSMutableDictionary new]; [repos enumerateObjectsUsingBlock:^(NSDictionary *repoDict, NSUInteger idx, BOOL * _Nonnull stop) { NSString *languageUrl = repoDict[@"languages_url"]; NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:languageUrl] completionHandler:^(NSData * _Nullable data, NSURLResponse *

Sending SPDY requests results in “The request timed out” errors with NSUrlSession in iOS

久未见 提交于 2020-01-04 14:14:47
问题 My iOS app loads images from an nginx HTTP server. After I send 400+ such requests the networking 'gets stuck' and all subsequent HTTP requests result in "The request timed out" error. I can make the images load again only when I restart the app. Details: I am using NSURLSession.sharedSession().dataTaskWithURL to send four hundred HTTP GET requests to jpeg files. Requests are sent sequentially, one after another. The interval between requests is 10 ms. Each previous unfinished request is

NSURLSessionDownloadTask issues with Storage almost full disk warnings

痴心易碎 提交于 2020-01-04 14:05:29
问题 I'm having issues with handling "out of space" / "full disk" errors on ios with NSURLSessionDownloadTask If the disk is full due to downloads done in the app I get a call to URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError error: NSError?) with the error having domain NSPOSIXErrorDomain and error code ENOSPC But this only happens once for a task, not for all running Ex: If I have 3 tasks running at the time, I only get this for one of them and the other 2 remain

How to fetch JSON data from a url using URLSession?

故事扮演 提交于 2020-01-04 13:44:32
问题 I am working on an iOS application in which I have to fetch data from this url . As I can see this url contain JSON data so here should I need to parse it or not I am not getting it how to get this JSON data. Here is my code. import UIKit import SwiftyJSON typealias ServiceResponse = (ApiResponseData, NSError?) -> Void class ApiManager: NSObject { var session:URLSession? = nil var urlRequest:URLRequest? = nil override init(){ super.init() urlRequest = URLRequest(url: URL(string:"https://dl

Clear NSURLSession Cache

这一生的挚爱 提交于 2020-01-04 09:39:10
问题 I'm using NSURLSession to perform an HTTP Post NSMutableURLRequest , using the dataTaskWithRequest:completionHandler: method. When I perform a request for the first time, things take a reasonable amount of time to complete and show some feedback in the completion handler. On the next time that same request is fired, it happens almost instantaneously with very little time in between, which leads me to believe that the system is caching the contents of this data task. As I don't need to view

Clear NSURLSession Cache

限于喜欢 提交于 2020-01-04 09:39:04
问题 I'm using NSURLSession to perform an HTTP Post NSMutableURLRequest , using the dataTaskWithRequest:completionHandler: method. When I perform a request for the first time, things take a reasonable amount of time to complete and show some feedback in the completion handler. On the next time that same request is fired, it happens almost instantaneously with very little time in between, which leads me to believe that the system is caching the contents of this data task. As I don't need to view