nsurlconnection

NSURLConnection - didReceiveData didn't get called - iOS & ARC

孤者浪人 提交于 2020-01-24 10:24:09
问题 I'm currently experimenting with the twitter streaming api and i'm trying to get a stream with NSURLConnection . As it doesn't work with twitter, i simplified everything and tried to get some source-code out of google's website, but this doesn't work neither. The connection starts and ends, but without calling the didReceiveData delegate. I'm sure i'm missing something. Hope you guy's can help me! In the header: @interface ViewController : UIViewController <NSURLConnectionDataDelegate,

How to gzip an NSURLConnection request?

此生再无相见时 提交于 2020-01-24 04:15:49
问题 Apparently, NSURLConnection automatically decodes gzipped responses. But, can it gzip encode its requests? If so, how? Or, does it do this automatically too? 回答1: An HTTP request body cannot be gzipped at the protocol level, as there is no way for the client to know whether the server supports that or not; it works for the server response because the client indicates in the request whether a gzipped response body can be accepted. (It could be done in the future something like how Expect: 100

Request Timeout NSURLSession

孤街浪徒 提交于 2020-01-23 12:39:17
问题 hello I used this below code to send a request to Server. How can I add the timeout in this function static func postToServer(url:String,var params:Dictionary<String,NSObject>, completionHandler: (NSDictionary?, String?) -> Void ) -> NSURLSessionTask { let request = NSMutableURLRequest(URL: NSURL(string: url)!) let session = NSURLSession.sharedSession() request.HTTPMethod = "POST" if(params["data"] != "get"){ do { let data = try NSJSONSerialization.dataWithJSONObject(params, options:

How I know the the posting data goes correctly

旧城冷巷雨未停 提交于 2020-01-22 01:39:07
问题 -(IBAction)clicked:(id)sender{ NSString *CIDString = cID.text; NSURL *url = [NSURL URLWithString:@"http://localhost:8080/test/?"]; NSString *postData = [NSString stringWithFormat:@"companyID=%@",CIDString]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[url standardizedURL] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60]; [request setHTTPMethod:@"POST"]; [request setValue:@"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@

can't receive a notification after posting inside connectionDidFinishLoading:, NSURLConnection delegate method

白昼怎懂夜的黑 提交于 2020-01-16 11:59:10
问题 I can't receive a notification with this: a class for doing NSURLConnection async stuff - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:_receivedData, @"receivedData", nil]; [[NSNotificationCenter defaultCenter] postNotificationName:kWebServiceURLTemperaturaMaximaKMLNotitificationName object:self userInfo:userInfo]; } another class observing the notification: [[NSNotificationCenter defaultCenter]

iPhone: Downloading data asynchronously with NSURL request as opposed to [NSData datawithContents ofURL]

梦想的初衷 提交于 2020-01-14 04:31:06
问题 Hi Im a newbie and Im trying to download geocoding data from googleapi webpage. I did it using this: code: NSMutableString *urlStr = [[NSMutableString alloc] initWithString:temp]; NSMutableString *address = [[NSMutableString alloc] initWithString:l.Address]; [address appendString:@" "]; [address appendString:l.CityName]; [address appendString:@" "]; [address appendString:l.State]; [address appendString:@" "]; [address appendString:l.PostalCode]; NSArray *addressArray = [address

Reachability on iPhone app with a false positive - will it get past apple?

僤鯓⒐⒋嵵緔 提交于 2020-01-13 19:20:08
问题 I am using this code... Reachability *r = [Reachability reachabilityWithHostName:@"www.maxqdata.com"]; NetworkStatus internetStatus = [r currentReachabilityStatus]; if ((internetStatus != ReachableViaWiFi) && (internetStatus != ReachableViaWWAN)) { UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"No Internet Connection" message:@"You require an internet connection via WiFi or cellular network for location finding to work." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil

Best way to measure download speed on iPhone using cocoa touch

依然范特西╮ 提交于 2020-01-13 03:15:30
问题 Im making an app where one of the features I want to offers is to measure de download speed of the connection. To get this I`m using NSURLConnection to start the download of a large file, and after some time cancel the download and make the calculation (Data downloaded / time elapsed). While other apps like speedtest.net give a constant speed every time, mine fluctuates 2-3 Mbps more or less. Basically what I`m doing is, start the timer when the method connection:didReceiveResponse: is called

iPhone SDK: URL request not timing out

眉间皱痕 提交于 2020-01-10 20:01:35
问题 I am having a problem with a network request that should timeout, but the method is not called. The request is as follows: #define kCONNECT_TIMEOUT 20.0 request = [NSMutableURLRequest requestWithURL: aUrl]; [request setHTTPMethod: @"POST"]; postData = [jsonData dataUsingEncoding:NSASCIIStringEncoding]; [request setHTTPBody:postData]; [request setValue:@"text/xml" forHTTPHeaderField:@"Accept"]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setCachePolicy

iOS - (kCFStreamErrorDomainSSL, -9813)

喜夏-厌秋 提交于 2020-01-07 05:08:24
问题 I'm getting (kCFStreamErrorDomainSSL, -9813) when connecting to a client's server. The client's server has a self signed certificate that I can not change. The app is using AFNetworking 3.x. I've tried the following but nothing seems to work. If someone could help me, it will be much appreciated. Info.plist: <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSExceptionDomains</key> <dict> <key