nsurlsession

NSURLCredentialStorage default credential not used automatically

╄→尐↘猪︶ㄣ 提交于 2020-01-03 01:20:10
问题 I'm switching from NSURLConnection to NSURLSession for my app communications and, while I'm at it, trying to move from delegated authentication to utilising NSURLCredentialStorage. I've moved over the code however I'm getting -URLSession:task:didReceiveChallenge being called on the delegate despite having set defaultCredentials on the sharedCredentialStorage when the app launches. The protection spaces are identical (the one I created when setting up the credentials and the ones passed by the

Manage completion handler of NSURLSession from a custom class

跟風遠走 提交于 2020-01-03 00:22:07
问题 Part of my app deals with creating a Login check for the user based on a unique code provided to them. To make my application properly structured, I've created a network Helper class to deal with all network operations. Here's How i call my helper class from the controller class (ViewController.m). [[LoginNetworkHelper alloc] loginBasedOnPatientId:@"abc"]; My LoginNetworkHelper class does the following tasks(LoginNetworkhelper.m) - (BOOL)loginBasedOnPatientId:(NSString *)patientId {

sessionWithConfiguration freezing iOS 8 iPhone 4S on new Xcode 6.0.1

二次信任 提交于 2020-01-02 23:14:22
问题 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

How to connect to a web service using NSURLSession with Delegate methods?

岁酱吖の 提交于 2020-01-02 12:25:08
问题 I am taking a stab at connecting to web services in iOS and I am running into a lot of problems. I found a practice web service here - http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit I have written this code out so far let soapMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" "

How to connect to a web service using NSURLSession with Delegate methods?

岁酱吖の 提交于 2020-01-02 12:25:06
问题 I am taking a stab at connecting to web services in iOS and I am running into a lot of problems. I found a practice web service here - http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit I have written this code out so far let soapMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" "

NSURLSession post : difference between uploadTask and dataTask

≡放荡痞女 提交于 2020-01-02 01:09:16
问题 These are my two examples : let config = NSURLSessionConfiguration.defaultSessionConfiguration() config.HTTPAdditionalHeaders = ["Accept": "application/json", "Content-Type": "application/json", "User-Agent": UIDevice.currentDevice().model] var request = NSMutableURLRequest(URL: NSURL(string: "http://XXX")) request.HTTPMethod = "POST" let valuesToSend = ["key":value, "key2":value] var error: NSError? let data = NSJSONSerialization.dataWithJSONObject(valuesToSend, options:NSJSONWritingOptions

How to know if NSURLSessionDataTask response came from cache?

瘦欲@ 提交于 2020-01-01 09:22:45
问题 I would like to determine if the response from NSURLSessionDataTask came from cache, or was served from server I'am creating my NSURLSessionDataTask from request.cachePolicy = NSURLRequestUseProtocolCachePolicy; 回答1: Two easy options come to mind: Call [[NSURLCache sharedURLCache] cachedResponseForRequest:request] before you make the request, store the cached response, then do that again after you finish receiving data, and compare the two cached responses to see if they are the same. Make an

does NSURLSession send user-agent automatically

旧巷老猫 提交于 2020-01-01 03:39:07
问题 Does NSURLSession send user-agent automatically when user WatchKit 2.0, iOS 9.0? Is there a way to verify this within the WatchKit app? 回答1: Yes, a user agent is automatically provided as part of the default session configuration. The default NSURLSession request header User-Agent field includes the Bundle Name ( CFBundleName ) and the Build Number ( CFBundleVersion ) of your watchOS app extension: $(CFBundleName)/$(CFBundleVersion) CFNetwork/808.3 Darwin/16.3.0 Notice that your app's Version

NSURLSession Memory Leaks occur when using web services in IOS

老子叫甜甜 提交于 2019-12-31 09:00:09
问题 I am building an app that uses a web service and to get information from that web service I use NSURLSession and NSURLSessionDataTask . I am now in the memory testing phase and I have found that NSURLSession is causing memory leaks. This is not all of the leaks. It is all that I could fit in the picture. Below is how I setup the NSURLSession and request the information from the web service. #pragma mark - Getter Methods - (NSURLSessionConfiguration *)sessionConfiguration { if (

NSURL returning nil for certain cases

无人久伴 提交于 2019-12-31 03:57:24
问题 I'm creating an NSURL to send as a request to a PHP rest API that I've got setup. Here's my code below: NSMutableString *url = [NSMutableString stringWithFormat:@"http://www.private.com/recievedata.php?item=%@&contact=%@&discovery=%@&summary=%@",__item,__contactDetails,__lostFound,__explain]; //The " ' " in PHP is a special character, so we have to escape it in the URL //The two slashes are because the "\" itself is a special character in Objective C NSString *formattedURL = [url