nsurlconnection

Error using NSURLConnection?

穿精又带淫゛_ 提交于 2019-12-11 07:39:58
问题 I am using following code NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:listUrl] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:180.0]; // create the connection with the request // and start loading the data NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; xmlData=[[NSMutableData alloc]init]; and when I run the project get follwing error in -(void)connection:(NSURLConnection *)connection

URL File Size With NSURLConnection - Swift

坚强是说给别人听的谎言 提交于 2019-12-11 06:54:18
问题 i am trying to get a file size from url before downloading here is the obj-c code NSURL *URL = [NSURL URLWithString:"ExampleURL"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL]; [request setHTTPMethod:@"HEAD"]; NSHTTPURLResponse *response; [NSURLConnection sendSynchronousRequest:request returningResponse:&response error: nil]; long long size = [response expectedContentLength]; and here is Swift Code var url:NSURL = NSURL(string: "ExmapleURL") var request

My app crashes when downloading large pdfs (>2MB) in iphone

喜夏-厌秋 提交于 2019-12-11 05:59:55
问题 My app is working fine for downloading small Pdf's and showing them in WebView but when i fetch url of pdfs having size more than 2 MB it crashes everytime. Code :- @implementation SecondViewController @synthesize scrollView,receivedData,myIndicator; - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [receivedData appendData:data]; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super

Packets dropped during chunked HTTP 1.1 request sent by NSURLConnection

冷暖自知 提交于 2019-12-11 05:23:16
问题 I am using the following code to set up a chunked HTTP 1.1 request (the request itself is a SOAP one but I don't think this is particularly important): NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url]; ... NSInputStream *dataStream = [NSInputStream inputStreamWithFileAtPath:_tempFilePath]; [request setHTTPBodyStream:dataStream]; self.p_connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES]; This seems to work fine except when

How to proceed with a service URL which is untrusted?

我的梦境 提交于 2019-12-11 04:54:02
问题 I am using a web service which is on a server with an invalid certificate but i want to get the response anyways. Is there a way to do it?? Here's the sample code: -(void)createHttpHeaderRequest:(serviceType)type { NSMutableURLRequest * theRequest; if (type==kServiceTypeTopAccessory) { NSString * test = @"{\"GetVehicleInventory\": {\"ApplicationArea\": some Json object here}}}}}"; NSString * final = (__bridge NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge

NSHTTPURLResponse different on iPhone 5 vs 5s

▼魔方 西西 提交于 2019-12-11 04:49:16
问题 This is officially the weirdest thing I've ever seen. I have an iPhone 5 and an iPhone 5s, both on iOS 7.1.2, completely clean. I run the following code: NSString *userAgent = @"Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3"; NSURL *url = [NSURL URLWithString: deviceString]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:url]; [request setValue:userAgent forHTTPHeaderField:@"User

Http live streaming: Forcing MPMoviePlayerController to pack headers in the http requests

会有一股神秘感。 提交于 2019-12-11 04:46:55
问题 I am streaming video from a server to iPhone using Http Live Streaming. I need to set certain headers in the http packets that the phone sends to the server. For regular packets, the following code would suffice: NSMutableURLRequest* request = [[[NSMutableURLRequest alloc] initWithURL:url] autorelease]; [request setValue:VALUE forHTTPHeaderField:@"Field You Want To Set"]; Unfortunately, I did not find a similar API for MPMoviePlayerController . In other words, how do I force

How to check the NSDATA type?

泪湿孤枕 提交于 2019-12-11 04:46:48
问题 I have the class which downloads images First I have NSMutable URLRequest than I establish NSURLConnection and than I want to check which data I received in this function - (void)connectionDidFinishLoading:(NSURLConnection *)connection If it is image than write to the folder when it is some text than skip to the next image. How do I check the type of received data? 回答1: In delegate method of NSURLConnection, you can get header of response, from which you can get content type. If content type

NSMutableData response string

戏子无情 提交于 2019-12-11 04:35:44
问题 I am trying to upload images to yFrog which is working just fine, but I want to grab just the URL from the response. When I use the NSURLConnection method - (void) connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; NSString* responseString = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding]; // NSString *url = [webData valueForKey:@"mediaurl"]; NSLog(@"result: %@", responseString); } I get this as my response string result: <?xml version="1.0"

NSURLConnection messes up iPad memory

北城余情 提交于 2019-12-11 03:27:11
问题 we build an iPad app that downloads a bunch of data and PDF documents from a web service (data first, documents later in the background). To do so, we use SOAP via HTTP(S) requests. It works fine and altogether, the app is running well. Problem is, if there are too many documents to download at some point the app crashes. Using Instruments I figured out that it is a memory issue, particularly NSRegularExpression and NSRunLoop. (I'm using ARC) I could improve my code to optimize the