nsurlsession

get file path when downloading with NSURLSession

好久不见. 提交于 2019-12-25 14:16:12
问题 I want to play music while downloading, so i play music with local file, how can i get file path in tmp directory while downloading with NSURLSession. The method URLSession:downloadTask:didFinishDownloadingToURL: than only call while file downloaded, so what should i do 回答1: If you want to get file location as it's being downloaded, just don't use download task. For example, create a NSURLSessionDataTask and stream it to persistent storage yourself (e.g. create your own NSOutputStream for

AFNetworking2 send parameter as query string in POST request?

点点圈 提交于 2019-12-25 06:40:02
问题 I need to send query string in URL as well as JSON in body while making POST request.To send query string in url i override HTTPMethodsEncodingParametersInURI property as suggested in this thread on SO like AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:fullUrl]]; manager.requestSerializer = [AFJSONRequestSerializer serializer]; manager.responseSerializer = [AFJSONResponseSerializer serializer]; manager.requestSerializer

NSUrlSession Running Slow in Swift

五迷三道 提交于 2019-12-25 03:39:14
问题 In swift I am downloading data in swift to my iOS app. It works just fine although what ends up happening is it can take up to 20 seconds for it to load even though I am on a fast connection. I don't understand why this happens. I was almost thinking about downloading all the data before the app opens although I don't want to do that because I know it is possible to speed it up which I know is possible because apps like YouTube and Facebook can load and refresh in less than 20 seconds. Heck,

Is it possible to use NSFileManager's `copyItemAtURL:toURL:error:` method when the app is in the background?

青春壹個敷衍的年華 提交于 2019-12-25 02:55:17
问题 I'm working on an iOS app, uploading videos from the Camera Roll, using NSURLSession with a background configuration. The user can queue up multiple videos for upload (the queue is executed serially). A single upload consists of: Getting an AVURLAsset reference to the PHAsset using PHImageManager's requestAVAssetForVideo method. Copying the resource to a temp directory (because you cannot upload straight from the AVURLAsset's URL). Uploading the resource using an NSURLSessionUploadTask I can

What is the AFNetworking 2 equivalent to ASIHTTPRequest setMaxConcurrentOperationCount

∥☆過路亽.° 提交于 2019-12-25 01:54:14
问题 I was trying to limit the max connections but couldn't find the method. Does anyone know how to do this? 回答1: Probably what you want to do is to set a custom NSURLSessionConfiguration by creating your own AFURLSessionManager with initWithSessionConfiguration: . The session configuration allows you to set HTTPMaximumConnectionsPerHost . If you're using AFHTTPRequestOperationManager then you can get its operationQueue and set maxConcurrentOperationCount on it. 来源: https://stackoverflow.com

Wait for task return on session.dataTask

北城以北 提交于 2019-12-24 18:28:22
问题 I have a project where I send and get data back from an API. Sending and getting it works fine. My goal is to wait a response (ie: yes|no) from the server and depending on it, proceed with the segue or not and show an alert if no. For this part I have: a tableview view with a list of clients and a button to add new client. a detail view where I add/edit a client on detail view there is a save button with a segue to the tableview view The function saveClient() gets the data and makes a request

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813) error not on all iPhones?

爷,独闯天下 提交于 2019-12-24 10:58:38
问题 one of my apps cannot connect to it's API server. The logged reason is NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813) . So far no luck on finding why or what, but the most frustrating thing is, that this problem appears on some of my test devices. On other everything is fine. I am using NSURLConnection:sendSynchronousRequest:returningResponse:error: , but after some refactoring and trying with NSURLSessionDataTask:dataTaskWithRequest:completionHandler: , the

Security concerns sending user name and password to server via https from iOS app

浪尽此生 提交于 2019-12-24 10:48:26
问题 I have set up in app purchase receipt verification in accordance with Apple's recommendations by sending the receipt to my server which in turn sends it to Apple's servers for verification. All my receipt processing is handled server side and it is working perfectly. My server sends back a very obscure code to my app to confirm whether the purchase is valid or not. I make use of a pretty robust obfuscation method on the app side to disguise what is going on with that return code to make it as

Append images in array in sequence

扶醉桌前 提交于 2019-12-24 09:26:49
问题 I want to add images in array in sequence after downloading. I am appending images in array after downloading one by one but they are not in sequence. Can any one please tell me what is best way to do this. var queue: NSOperationQueue = { let _queue = NSOperationQueue() _queue.maxConcurrentOperationCount = 4 return _queue }() var imageArrayNsData : [NSData] = [] let session = NSURLSession.sharedSession() @IBAction func didClickOnStart(sender: AnyObject) { queue.cancelAllOperations() let

Downloading images in UITableViewCell: Data vs URLSession?

你。 提交于 2019-12-24 08:46:38
问题 I have a UITableView and I need each of its cells to download an image from a provided URL and show it. This looks to be a quite common scenario and indeed I found several posts and questions related to this, but I am not still clear about which the best approach should be. First one, I have one using Data(contentsOf:) . This is the code I have in my UITableViewCell : class MyCell: UITableViewCell { @IBOutlet weak var activityIndicator: UIActivityIndicatorView! @IBOutlet weak var imageView: