Search Results

Search found 244 results on 10 pages for 'nsurlconnection'.

Page 1/10 | 1 2 3 4 5 6 7 8 9 10  | Next Page >

  • Asynchronous NSURLConnection Throws EXC_BAD_ACCESS

    - by Sheehan Alam
    I'm not really sure why my code is throwing a EXC_BAD_ACCESS, I have followed the guidelines in Apple's documentation: -(void)getMessages:(NSString*)stream{ NSString* myURL = [NSString stringWithFormat:@"http://www.someurl.com"]; NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:myURL]]; NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if (theConnection) { receivedData = [[NSMutableData data] retain]; } else { NSLog(@"Connection Failed!"); } } And my delegate methods #pragma mark NSURLConnection Delegate Methods - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { // This method is called when the server has determined that it // has enough information to create the NSURLResponse. // It can be called multiple times, for example in the case of a // redirect, so each time we reset the data. // receivedData is an instance variable declared elsewhere. [receivedData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { // Append the new data to receivedData. // receivedData is an instance variable declared elsewhere. [receivedData appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { // release the connection, and the data object [connection release]; // receivedData is declared as a method instance elsewhere [receivedData release]; // inform the user NSLog(@"Connection failed! Error - %@ %@", [error localizedDescription], [[error userInfo] objectForKey:NSErrorFailingURLStringKey]); } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { // do something with the data // receivedData is declared as a method instance elsewhere NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]); // release the connection, and the data object [connection release]; [receivedData release]; } I get an EXC_BAD_ACCESS on didReceiveData. Even if that method simply contains an NSLog, I get the error. Note: receivedData is an NSMutableData* in my header file

    Read the article

  • Memory management for NSURLConnection

    - by eman
    Sorry if this has been asked before, but I'm wondering what the best memory management practice is for NSURLConnection. Apple's sample code uses -[NSURLConnection initWithRequest:delegate:] in one method and then releases in connection:didFailWithError: or connectionDidFinishLoading:, but this spits out a bunch of analyzer warnings and seems sort of dangerous (what if neither of those methods is called?). I've been autoreleasing (using +[NSURLConnection connectionWithRequest:delegate:]), which seems cleaner, but I'm wondering--in this case, is it at ever possible for the NSURLConnection to be released before the connection has closed?

    Read the article

  • Unable to use NSURLConnection to get contents of password/username protected webpage

    - by bubster
    I am trying to get the contents of a webpage that requires a password and user name to access. I am using a NSURLConnection object to get it however when I write the NSMutableData object that is returned to a file all I get is the login page. Normally when you try to load the password protected page when you are not logged in it redirects to the login page however I thought that if I provided valid credentials then this I would be able to view the password protected page. Also I do not know if it is relevant the website is using a microsoft mysql database on an IIS (internet information server). Note: [protectionSpace authenticationMethod] returns NSURLAuthenticationMethodServerTrust I am pretty unfamiliar with this so any ideas would be greatly appreciated. Below is all of the relevant code: - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { // This method is called when the server has determined that it // has enough information to create the NSURLResponse. // It can be called multiple times, for example in the case of a // redirect, so each time we reset the data. // receivedData is an instance variable declared elsewhere. [receivedData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { // Append the new data to receivedData. // receivedData is an instance variable declared elsewhere. [receivedData appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { // release the connection, and the data object //[connection release]; // receivedData is declared as a method instance elsewhere //[receivedData release]; // inform the user NSLog(@"Connection failed! Error - %@ %@", [error localizedDescription], [[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]); } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { // do something with the data // receivedData is declared as a method instance elsewhere NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]); // release the connection, and the data object //[connection release]; //[receivedData release]; //Write data to a file [receivedData writeToFile:@"/Users/matsallen/Desktop/receivedData.html" atomically:YES]; } - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace: (NSURLProtectionSpace *)protectionSpace { NSLog(@"The connection encountered a protection space. The authentication method is %@", [protectionSpace authenticationMethod]); secureTrustReference = [protectionSpace serverTrust]; //SecTrustResultType *result; //OSStatus status = SecTrustEvaluate(secureTrustReference, result); //NSLog(@"Result of the trust evaluation is %@",status); return YES; } - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { NSURLCredential *newCredential; newCredential = [NSURLCredential credentialWithUser:@"username" password:@"password" persistence:NSURLCredentialPersistenceForSession]; newCredential = [NSURLCredential credentialForTrust:secureTrustReference]; // [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge]; // [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; } #pragma mark - View lifecycle - (void)viewDidLoad { receivedData = [[NSMutableData alloc] init]; [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. // Create the request. NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.markallenonline.com/secure/maoCoaching.aspx"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; // create the connection with the request // and start loading the data NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if (theConnection) { // Create the NSMutableData to hold the received data. // receivedData is an instance variable declared elsewhere. receivedData = [NSMutableData data]; NSLog(@"Connection succeeded!"); } else { // Inform the user that the connection failed. NSLog(@"Connection failed!"); } }

    Read the article

  • NSURLConnection shown as leaking in instruments

    - by Gyozo Kudor
    Hello another stupid question regarding leaks and also NSURLConnection. How do i release it? Is it enough if i release in the following 2 methods? (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error (void)connectionDidFinishLoading:(NSURLConnection *)connection Because in instruments it shows me the line where I alloc my connection as the source of leaking. OK I don't get it. After the following code my urlConnection has a retain count of 2. WTF? NSURLConnection *urlConnection = [[NSURLConnection alloc] initWithRequest: urlRequest delegate: self]; This is the line that instruments points me to. I find this very weird.

    Read the article

  • strange multiple files download - NSURLConnection

    - by Georg
    hi all, I encounter a problem by following your comment. I would like to download different file at same time with different delegate: .h: NSMutableData *fileData; .m: NSString *imgfile = [NSString stringWithFormat:@"http://xxxx/01.jpg"]; NSURL *fileURL1 = [NSURL URLWithString:imgfile]; NSString *audiofile = [NSString stringWithFormat:@"http://xxxx/01.mp3"]; NSURL *fileURL2 = [NSURL URLWithString:audiofile]; NSURLRequest *request1 = [NSURLRequest requestWithURL:fileURL1 cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0 ]; NSURLRequest *request2 = [NSURLRequest requestWithURL:fileURL2 cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0 ]; NSArray *connections = [[NSArray alloc] initWithObjects: [[NSURLConnection alloc] initWithRequest:request1 delegate:self ], [[NSURLConnection alloc] initWithRequest:request2 delegate:self ], nil]; - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { fileData = [[NSMutableData alloc] init]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [fileData appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"Unable to fetch data"); } ok, the download process works, but, the file size of jpg and mp3 are incorrect, the only correct thing is the total file size (jpg+mp3), please could you have a look on the code, what is missing? Another question is, I put the file in a NSMutableArray, my question is, how to check which index of array is the correct file type (jpg and mp3)? because I need to save them to the device folder.

    Read the article

  • NSURLConnection request seems to disappear into thin air

    - by ibergmark
    Hi Everybody! I'm having trouble with a NSURLConnection request. My app calls a routine called sayHello to identify a user's device. This code works fine for all devices I've tested it on, but for some devices the request just seems to disappear into thin air with no errors or popups on the device. One specific device that fails is an iPod Touch 2G running OS 3.1.3. The app start's fine and doesn't crash, and none of my error popup messages are displayed. I just can't understand why my server never receives the request since the call to initWithRequest returns a pointer. Any help is much appreciated. Thanks. Here's the relevant header info: @interface Globals : NSObject { UserItem *userData; NSURLConnection *urlConnection; NSString *imageCacheLocation; NSOperationQueue *opQueue; } Here's the implementation of sayHello: - (void)sayHello:(BOOL)updateVisits; { NSString *updString; if (updateVisits) updString = @"Y"; else updString = @"N"; NSDictionary *dataDict = [[NSDictionary alloc] initWithObjectsAndKeys: [[UIDevice currentDevice] uniqueIdentifier], @"id", kProgVersion, @"pv", @"1", @"pr", userData.tagID, @"tg", updString, @"uv", nil]; NSString *urlString = [[NSString alloc] initWithString:kHelloURL]; urlConnection = [self localPOST:dataDict toUrl:urlString delegate:self]; [dataDict release]; [urlString release]; } - (NSURLConnection *)localPOST:(NSDictionary *)dictionary toUrl:(NSString *)urlString delegate:(id)delegate { NSString *myBounds = [[NSString alloc] initWithString:@"0xKmYbOuNdArY"]; NSMutableData *myPostData = [[NSMutableData alloc] initWithCapacity:10]; NSArray *formKeys = [dictionary allKeys]; for (int i = 0; i < [formKeys count]; i++) { [myPostData appendData:[[NSString stringWithFormat:@"--%@\n", myBounds] dataUsingEncoding:NSUTF8StringEncoding]]; [myPostData appendData:[[NSString stringWithFormat: @"Content-Disposition: form-data; name=\"%@\"\n\n%@\n", [formKeys objectAtIndex:i], [dictionary valueForKey:[formKeys objectAtIndex:i]]] dataUsingEncoding:NSUTF8StringEncoding]]; } [myPostData appendData:[[NSString stringWithFormat:@"--%@--\n", myBounds] dataUsingEncoding:NSUTF8StringEncoding]]; NSURL *myURL = [[NSURL alloc] initWithString:urlString]; NSMutableURLRequest *myRequest = [[NSMutableURLRequest alloc] initWithURL:myURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]; NSString *myContent = [[NSString alloc] initWithFormat: @"multipart/form-data; boundary=%@", myBounds]; [myRequest setValue:myContent forHTTPHeaderField:@"Content-Type"]; [myRequest setHTTPMethod:@"POST"]; [myRequest setHTTPBody:myPostData]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:myRequest delegate:delegate]; if (!connection) { [[Globals sharedGlobals] showAlertWithTitle: NSLocalizedString( @"Connection failed", @"alert title - connection failed") message: NSLocalizedString( @"Could not open a connection.", @"alert message - connection failed")]; } [myBounds release]; [myPostData release]; [myURL release]; [myRequest release]; [myContent release]; return connection; } - (void)handleNetworkError:(NSError *)error { if (networkErrorAlert) return; networkErrorAlert = YES; [[Globals sharedGlobals] showAlertWithTitle: NSLocalizedString( @"Network error", @"alert title - network error") message: [NSString stringWithFormat: NSLocalizedString( @"This app needs a network connection to function properly.", @"alert message - network error")] otherButtons:nil delegate:self]; } - (void) connectionDidFinishLoading:(NSURLConnection *)connection { [urlConnection release]; urlConnection = nil; } - (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { [self handleNetworkError:error]; [urlConnection release]; urlConnection = nil; }

    Read the article

  • NSURLConnection receives data even if no data was thrown back

    - by Anna Fortuna
    Let me explain my situation. Currently, I am experimenting long-polling using NSURLConnection. I found this and I decided to try it. What I do is send a request to the server with a timeout interval of 300 secs. (or 5 mins.) Here is a code snippet: NSURL *url = [NSURL URLWithString:urlString]; NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageAllowedInMemoryOnly timeoutInterval:300]; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&resp error:&err]; Now I want to test if the connection will "hold" the request if no data was thrown back from the server, so what I did was this: if (data != nil) [self performSelectorOnMainThread:@selector(dataReceived:) withObject:data waitUntilDone:YES]; And the function dataReceived: looks like this: - (void)dataReceived:(NSData *)data { NSLog(@"DATA RECEIVED!"); NSString *string = [NSString stringWithUTF8String:[data bytes]]; NSLog(@"THE DATA: %@", string); } Server-side, I created a function that will return a data once it fits the arguments and returns none if nothing fits. Here is a snippet of the PHP function: function retrieveMessages($vardata) { if (!empty($vardata)) { $result = check_data($vardata) //check_data is the function which returns 1 if $vardata //fits the arguments, and 0 if it fails to fit if ($result == 1) { $jsonArray = array('Data' => $vardata); echo json_encode($jsonArray); } } } As you can see, the function will only return data if the $result is equal to 1. However, even if the function returns nothing, NSURLConnection will still perform the function dataReceived: meaning the NSURLConnection still receives data, albeit an empty one. So can anyone help me here? How will I perform long-polling using NSURLConnection? Basically, I want to maintain the connection as long as no data is returned. So how will I do it? NOTE: I am new to PHP, so if my code is wrong, please point it out so I can correct it.

    Read the article

  • iOs receivedData from NSURLConnection is nil

    - by yhl
    I was wondering if anyone could point out why I'm not able to capture a web reply. My NSLog shows that my [NSMutableData receivedData] has a length of 0 the entire run of the connection. The script that I hit when I click my login button returns a string. My NSLog result is pasted below, and after that I've pasted both the .h and .m files that I have. NSLog Result 2012-11-28 23:35:22.083 [12548:c07] Clicked on button_login 2012-11-28 23:35:22.090 [12548:c07] theConnection is succesful 2012-11-28 23:35:22.289 [12548:c07] didReceiveResponse 2012-11-28 23:35:22.290 [12548:c07] didReceiveData 2012-11-28 23:35:22.290 [12548:c07] 0 2012-11-28 23:35:22.290 [12548:c07] connectionDidFinishLoading 2012-11-28 23:35:22.290 [12548:c07] 0 ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController // Create an Action for the button. - (IBAction)button_login:(id)sender; // Add property declaration. @property (nonatomic,assign) NSMutableData *receivedData; @end ViewController.m #import ViewController.h @interface ViewController () @end @implementation ViewController @synthesize receivedData; - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { NSLog(@"didReceiveResponse"); [receivedData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { NSLog(@"didReceiveData"); [receivedData appendData:data]; NSLog(@"%d",[receivedData length]); } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"connectionDidFinishLoading"); NSLog(@"%d",[receivedData length]); } - (IBAction)button_login:(id)sender { NSLog(@"Clicked on button_login"); NSString *loginScriptURL = [NSString stringWithFormat:@"http://www.website.com/app/scripts/login.php?"]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:loginScriptURL]]; NSString *postString = [NSString stringWithFormat:@"&paramUsername=user&paramPassword=pass"]; NSData *postData = [postString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody:postData]; // Create the actual connection using the request. NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; // Capture the response if (theConnection) { NSLog(@"theConnection is succesful"); } else { NSLog(@"theConnection failed"); } } @end

    Read the article

  • NSURLConnection performance

    - by oksk
    Hi all, I'm using NSURLConnection for downloading some images in my app currently. Before implementing via this, I implemented it by NSData(dataWithContentOfURL) in NSThread. But I wanted to cancel during downloading images, So I changed it to NSURLConnection. But It happens other problem. Performance was very low after changing. For example, There is at least 5seconds for downloading images at NSThread(NSData async) But, There is more than 2 or 3 times than it at NSURLConnection(async) !! Can I enhance performance ?? How?? (* sorry about my question with NSData(dataWithContentOfFile). correct question is dataWithContentOfURL)

    Read the article

  • Why release the NSURLConnection instance in this statement?

    - by aquaibm
    I read this in a book. -(IBAction) updateTweets { tweetsView.text = @""; [tweetsData release]; tweetsData = [[NSMutableData alloc] init]; NSURL *url = [NSURL URLWithString:@"http://twitter.com/statuses/public_timeline.xml" ]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL: url]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [connection release]; [request release]; [activityIndicator startAnimating]; } In this statement,is that correct to release the "connection" instance at that time? After releasing it which means this NSURLConnection instance will be destroyed since it's reference count is 0 ,how are we going to make this connection operation work? THANKS.

    Read the article

  • error handling with NSURLConnection sendSynchronousRequest

    - by Nnp
    how can i do better error handling with NSURLConnection sendSynchronousRequest? is there any way i can implement - (void)connection:(NSURLConnection *)aConn didFailWithError:(NSError *)error i have a nsoperation queue which is getting data in background thats why i have sync request. and if i have to implement async request then how can i wait for request to get complete. because that method can't proceed without data.

    Read the article

  • When to call release on NSURLConnection delegate?

    - by Kieran H
    Hi, When passing a delegate to the a NSUrlConnection object like so: [[NSURLConnection alloc] initWithRequest:request delegate:handler]; when should you call release on the delegate? Should it be in connectionDidFinishLoading? If so, I keep getting exec_bad_access. I'm seeing that my delegates are leaking through instruments. Thanks

    Read the article

  • iPhone NSURLConnection through Proxy+Auth

    - by woody993
    I am using NSURLConnection to make connections to a server, through a proxy that requires authentication this fails. The proxy settings are set under the WiFi, but the connection still fails. I believe there is a part of CFNetwork that can fix this, but this might be just for streams and I am unsure of how to implement it with NSURLConnection. How can I tell my application to use the proxy settings set under WiFi?

    Read the article

  • Update iPhone UIProgressView during NSURLConnection download.

    - by Scott Pendleton
    I am using this code: NSURLConnection *oConnection=[[NSURLConnection alloc] initWithRequest:oRequest delegate:self]; to download a file, and I want to update a progress bar on a subview that I load. For that, I use this code: - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [oReceivedData appendData:data]; float n = oReceivedData.length; float d = self.iTotalSize; NSNumber *oNum = [NSNumber numberWithFloat:n/d]; self.oDPVC.oProgress.progress = [oNum floatValue]; } The subview is oDPVC, and the progress bar on it is oProgress. Setting the progress property does not update the control. From what I have read on the Web, lots of people want to do this and yet there is not a complete, reliable sample. Also, there is much contradictory advice. Some people think that you don't need a separate thread. Some say you need a background thread for the progress update. Some say no, do other things in the background and update the progress on the main thread. I've tried all the advice, and none of it works for me. One more thing, maybe this is a clue. I use this code to load the subview during applicationDidFinishLaunching: self.oDPVC = [[DownloadProgressViewController alloc] initWithNibName:@"DownloadProgressViewController" bundle:nil]; [window addSubview:self.oDPVC.view]; In the XIB file (which I have examined in both Interface Builder and in a text editor) the progress bar is 280 pixels wide. But when the view opens, it has somehow been adjusted to maybe half that width. Also, the background image of the view is default.png. Instead of appearing right on top of the default image, it is shoved up about 10 pixels, leaving a white bar across the bottom of the screen. Maybe that's a separate issue, maybe not.

    Read the article

  • Why is my NSURLConnection so slow?

    - by Bama91
    I have setup an NSURLConnection using the guidelines in Using NSURLConnection from the Mac OS X Reference Library, creating an NSMutableURLRequest as POST to a PHP script with a custom body to upload 20 MB of data (see code below). Note that the post body is what it is (line breaks and all) to exactly match an existing desktop implementation. When I run this in the iPhone simulator, the post is successful, but takes an order of magnitude longer than if I run the equivalent code locally on my Mac in C++ (20 minutes vs. 20 seconds, respectively). Any ideas why the difference is so dramatic? I understand that the simulator will give different results than the actual device, but I would expect at least similar results. Thanks const NSUInteger kDataSizePOST = 20971520; const NSString* kServerBDC = @"WWW.SOMEURL.COM"; const NSString* kUploadURL = @"http://WWW.SOMEURL.COM/php/test/upload.php"; const NSString* kUploadFilename = @"test.data"; const NSString* kUsername = @"testuser"; const NSString* kHostname = @"testhost"; srandom(time(NULL)); NSMutableData *uniqueData = [[NSMutableData alloc] initWithCapacity:kDataSizePOST]; for (unsigned int i = 0 ; i < kDataSizePOST ; ++i) { u_int32_t randomByte = ((random() % 95) + 32); [uniqueData appendBytes:(void*)&randomByte length:1]; } NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:kUploadURL]]; [request setHTTPMethod:@"POST"]; NSString *boundary = @"aBcDd"; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary]; [request addValue:contentType forHTTPHeaderField: @"Content-Type"]; NSMutableData *postbody = [NSMutableData data]; [postbody appendData:[[NSString stringWithFormat:@"--%@\nContent-Size:%d",boundary,[uniqueData length]] dataUsingEncoding:NSUTF8StringEncoding]]; [postbody appendData:[[NSString stringWithFormat:@"\nContent-Disposition: form-data; name=test; filename=%@", kUploadFilename] dataUsingEncoding:NSUTF8StringEncoding]]; [postbody appendData:[[NSString stringWithString:@";\nContent-Type: multipart/mixed;\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [postbody appendData:[NSData dataWithData:uniqueData]]; [postbody appendData:[[NSString stringWithFormat:@"--%@\nContent-Size:%d",boundary,[kUsername length]] dataUsingEncoding:NSUTF8StringEncoding]]; [postbody appendData:[[NSString stringWithFormat:@"\nContent-Disposition: inline; name=Username;\n\r\n%@",kUsername] dataUsingEncoding:NSUTF8StringEncoding]]; [postbody appendData:[[NSString stringWithFormat:@"--%@\nContent-Size:%d",boundary,[kHostname length]] dataUsingEncoding:NSUTF8StringEncoding]]; [postbody appendData:[[NSString stringWithFormat:@"\nContent-Disposition: inline; name=Hostname;\n\r\n%@",kHostname] dataUsingEncoding:NSUTF8StringEncoding]]; [postbody appendData:[[NSString stringWithFormat:@"\n--%@--",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:postbody]; NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; if (theConnection) { _receivedData = [[NSMutableData data] retain]; } else { // Inform the user that the connection failed. } [request release]; [uniqueData release];

    Read the article

  • how secure is NSURLConnection over https

    - by drunken_elf
    I've been reading through a number of questions on this site regarding NSURLConnection and https, but most relate to "untrusted" certificates and how to allow them nonetheless. My question is a little more basic. I am building an app for a client who handle online donations, and I would like to load their donation script using an NSLURLRequest and POST the values of credit card details (entered in the app). Does NSURLConnection (when connecting to a https url) ensure the encryption of those details as they are sent to the donation script on my clients server? Sorry if this is a basic question, I just couldn't find a place in the apple docs that guaranteed this.

    Read the article

  • Does Multiple NSURLConnection make delay of performance?

    - by oksk
    Hi all~. I made a multi files downloader. I implemented NSURLConnection using NSOperationQueue. NSOpetationQueue has many NSURLConnection operations. and, set MaxConcurrentOperationCount to 10. I thought my code is right, But after run the project, it was wrong. there are some connection error has occured. files url were right. and file download was completed. but downloading files, occur "timed out" error. It is so serious. I tested it with 8 files, and those total size is only 3M. But total download time is 2minutes ~!!! one file download spends only a few second. (2~3 s) but multi files download occur many overburden!! (2 minutes) I don't know why it is... Do Anyone know what reason is?

    Read the article

  • NSURLConnection on simulator and iphone performance issues

    - by Nava Carmon
    I'm experiencing a weird problem and i wonder if anybody else has noticed this: I'm using NSURLConnection as it appears in apple's examples to get xml files from a certain server - pretty straight forward. And most of time it works, but sometimes it's just stuck after initialing and don't get into connection's delegate methods. I'm working with WiFi & 3G and the same server all the time. When it comes to didFailWithError i see that mostly it was a timeout error. When I enter same link in Safari it takes a second to bring data. And after another trial I can access the link. What might be the reason for such a weird behavior? How can I improve it? What is the role of cache policy with NSURLConnection? Thanks, Nava

    Read the article

  • disable keep-alive in NSURLConnection

    - by Nava Carmon
    How can disable keep-alive when using NSURLConnection? Seems, that after cancelling and close it it still saves somewhere a socket that I was connected to server with and while the server fetches for information i cannot access another urls from the same server. I wonder if there is a way to completely reset a socket and start another one. Thanks, Nav

    Read the article

  • iPhone - NSURLConnection does not receive data

    - by Jukurrpa
    Hi, I have a pretty weird problem with NSURLRequest. I'm using them to make an asynchronous image loading in an UITableView. The first time the tableView displays, all connections from NSURLRequests open correctly but receive absolutely no data, regardless of how long I wait. But as soon as I scroll down in the tableView, the newly created requests for the new cells work perfectly! The only way for the images on top of the tableView to load is to make them disappear by scrolling down and then up again, in order to create new requests. Here is what I do in "cellForRowAtIndexPath": UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; if (cell == nil) { cell = [[UITableViewCell alloc] initWIthFrame:CGRectMake(0, 0, 300, 60)]; AsyncUIImageView imageView = [[AsynUIImageView alloc] initWithFrame:CGRectMake(0, 0, 60, 60)]; imageView.tag = IMG_VIEW // an enum for tags [cell addSubView:imageView]; [imageView release]; } AsyncUIImageView imageView = (AsyncUIImageView*)[cell viewWithTag:IMG_VIEW]; // I do a few cache checks here, but if the image aint cached I do this: [imageView loadImageFromURL:@"http://someurl.com/somepix.jpg"]; // all urls are different, just an example The AsyncUIImageView inherits from UIImageView and contains an NSURLConnection which opens upon calling the loadImageFromURL method: (void) loadImageFromURL:(NSString*)filename { if (self.connection != nil) [self.connection release]; if (self.data != nil) [self.data release]; NSURLRequest* request = [NSURLRequest requestWithURL:[[NSURL alloc] initWithString:fileName] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; self.connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; if (self.connection == nil) return; self.data = [[NSMutableData data] retain]; } I've created the delegate methods "connection: didReceiveData", which appends received data to self.data and "connectionDidFinishLoading" which sets the image and closes the connection once the transfer is complete. These work, but are never called for the first requests I create. I suspect this bug to come from the main thread not giving the first requests the control so they can execute themselves, as the same behavior happens if I keep my finger on the screen after a scroll: connections open themselves, but no data is received until I stop touching the screen. What am I doing wrong?

    Read the article

  • Using NSURLRequest+NSURLConnection seems overkill for a webcall with no data return

    - by Spectravideo328
    All, This might seems very straightforward but I have already gone through the URL loading system program guide and the various NSURL.... classes and not found my answer. I am just trying to do a simple call from the app to a website to reserve a party spot: NSString *path=[NSString stringWithFormat:@"http://www.myparty123.com/ireservedURL.asp?Nickname=%@&Seat=%i&Email=%@&Currentparty=%i",john,5432,[email protected],6598]; NSURL* reservationURL =[NSURL URLWithString:path]; NSData *call= [NSData dataWithContentsOfURL:reservationURL]; This seemed to be the simple way but I get this warning that I am not using the "call" variable. And it seems overkill to do a call using NSData where there is no data return. Yet, creating an NSURLRequest and initiating an NSURLConnection and then implementing delegates with that request seems to be overkill as well. What am I missing. Thanks KMB

    Read the article

  • Using a proxy for NSURLConnection

    - by SideSwipe
    Is there any way to get the content of a webfile (namely a .html Document) using a proxy, which is not defined in the system settings? I know that NSURLConnection is the right way to download a web file into a variable and not into a file (for which we should use NSURLDownload), but I don't find a way to use a proxy for it. Are there some unofficial APIs, Libraries or Classes or such I could use for what I want to do? I'm not that pro in Mac Programming, so I'm searching for something more or less simple. SideSwipe

    Read the article

  • Catching the redirected address from NSURLConnection

    - by Vic
    I'm working on a software which follows the HTTP redirection which is dynamically calculated by the server depending on a pparameter. I don't want to show the primary server in Mobile Safari but rather the redirected address only. The following code workks: request = [NSMutableURLRequest requestWithURL:originalUrl cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10]; [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; // Extract the redirected URL target = [response URL]; The problem is that the server requires several seconds to answer. The sendSynchronousRequest blocks the app for this time completely which is messy, I can't even display the "Busy" animation. Does anyone know how I can retrieve the redirected address asynchronously without safari appearance in the meanwhile with the redirecting server URL or display some sort of the "Be patient" animation during the sendSynchronousRequest? What disadvantages would have the passing of sendSynchronousRequest in another thread?

    Read the article

1 2 3 4 5 6 7 8 9 10  | Next Page >