nsurlsession

sessionWithConfiguration freezing iOS 8 iPhone 4S on new Xcode 6.0.1

蓝咒 提交于 2019-12-07 07:44:25
I am experiencing a disturbing issue when trying to execute one of my apps on an iPhone 4S with iOS8 and Xcode 6.0.1. What happens is that the control seems to freeze in the last instruction of the block: dispatch_once(&onceToken, ^{ NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:@"myBackgroundSessionIdentifier"]; NSLog(@"configuration=%@", configuration); configuration.allowsCellularAccess = YES; configuration.timeoutIntervalForRequest = 30.0; configuration.timeoutIntervalForResource = 60.0; configuration

Difference between multipart form upload and NSURLSession.uploadTaskWithRequest

岁酱吖の 提交于 2019-12-07 05:31:35
问题 Coming from the world of web programming, I'm pretty much comfortable with working with multipart form requests to upload files. However, in iOS, we have a thing called NSURLSession with the method uploadTaskWithRequest , which seems to be the method to call to do image uploads and the likes. Can you explain the difference between the two approach, multipart form upload vs uploadTaskWithRequest ? If I already have a backend that handle multipart form uploads, what kind of adjustments that I

Always getting back cached data in NSURLSessionDataTask

放肆的年华 提交于 2019-12-07 04:24:52
问题 I'm facing a very strange issue when using NSURLSessionDataTask to post a JSON request to the server. The first request goes through and I receive the correct JSON response, when I do a second request I'm getting always back the old response and the server never receives the request. Even if I turn on airplane mode the NSURLSessionDataTask does work an I get back the old response again. That's the code I'm using: - (void)getJSONFromURL:(NSURL*)url identifierCode:(NSInteger)code {

NSURLSessionDownloadTaskDelegate JSON response

北慕城南 提交于 2019-12-07 02:32:11
问题 I am running a background NSURLSession session and i am trying to figure out a way to get the JSON response out of one of the NSURLDownloadTaskDelegate callbacks. I have configured my session to accept JSON responses. NSURLSessionConfiguration *backgroundSession = [NSURLSessionConfiguration backgroundSessionConfiguration:@"com.Att.Locker.BackgroundUpload"]; backgroundSession.HTTPAdditionalHeaders = @{ @"Accept":@"application/json"}; session = [NSURLSession sessionWithConfiguration

Upload large video via NSURLSession causes memory pressure crash

↘锁芯ラ 提交于 2019-12-07 01:42:30
问题 I use the following codes to upload video to server, which requires me to convert the video from video format to NSData . However, when the video is large (e.g. 10 minute video), the App crashes due to memory pressure. How can I resolve this? - (void)uploadVideo { NSDictionary *params = nil; NSString *NSURLSessionIdentifier = [NSString stringWithFormat:@"%@%@",@"my.bundle.identifier.",[self getTimeString]]; NSURLSessionConfiguration *sessionConfig; // SessionConfiguration With iOS Version if

totalBytesExpectedToWrite is -1 in NSURLSessionDownloadTask

孤街浪徒 提交于 2019-12-07 01:26:53
问题 I faced with a strange problem. I load file from the Internet using NSURLSession and NSURLSessionDownloadTask . Here is the code NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfiguration:kSessionId]; self.session = [NSURLSession sessionWithConfiguration:sessionConfiguration delegate:self delegateQueue:[NSOperationQueue new]]; NSURL *url = [NSURL URLWithString:urlString]; NSURLRequest *request = [NSURLRequest requestWithURL:url];

Pause,Resume,Cancel Upload Task Using NSURLSession UploadTask

对着背影说爱祢 提交于 2019-12-06 23:37:33
问题 I am developing an app to upload multiple files using NSURLSession, right now my files are successfully uploaded. But now what i want to achieve is to pause,resume and cancel the uploads just like we do in download tasks. Is it possible.? Any help would be appreciated. Thnx 回答1: I have studied alot but could find nothing .After i tried this on my code assuming this as a download task ,I came to know that we can "pause , resume" upload tasks as well using NSURLSession just we do in downloading

Post request with raw body using NSURLSession

我怕爱的太早我们不能终老 提交于 2019-12-06 21:36:45
I have stuck here. Below is my code for Post request with raw body using NSURLSession. I got response = NULL and no error. NSString* stringRequest = @"https://chocudan.com/api/shops/by_ids"; NSURL* urlRequest = [NSURL URLWithString:stringRequest]; NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:urlRequest]; request.HTTPMethod = @"POST"; NSString* bodyRequest = @"563c268b84ba489c4729f149"; //I have to tried a base64 convert here but still not work. //request.HTTPBody = [NSData base64DataFromString:bodyRequest]; request.HTTPBody = [bodyRequest dataUsingEncoding

what is the advantage of using Alamofire over NSURLSession/NSURLConnection for networking?

烈酒焚心 提交于 2019-12-06 16:57:04
问题 Can anyone help me in understanding these question : What is the advantage of using Alamofire over NSURLSession/ NSURLConnection? What are the differences between NSURLSession and NSURLConnection? 回答1: NSURLConnection is Apple's old API for doing networking (e.g. making HTTP requests and receiving responces), while NSURLSession is their new one. The latter one is higher level and is generally much easier and involves less boilerplate code to use for most application developers - there's

Moving from NSURLConnection to NSURLSession for SOAP POST in Swift

佐手、 提交于 2019-12-06 16:38:49
I am trying to move over from NSURLConnection over to NSURLSession for a SOAP post, but seem to have issues with the NSURLSessionDataDelegate. Here is the old code in NSURLConnection that works fine: let soapMessage = "<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ns1='http://tempuri.org/'><SOAP-ENV:Body><ns1:get_Countries/></SOAP-ENV:Body></SOAP-ENV:Envelope>" print("Soap Packet is \(soapMessage)") let urlString = "https://example.com/Service.svc" let url = NSURL(string: urlString) let theRequest = NSMutableURLRequest