nsurlconnection

NSURLConnection connection:didReceiveData: is not called on ios5

淺唱寂寞╮ 提交于 2019-12-10 11:28:55
问题 A weird problem. I wanna load an image from web, so i use NSURLConnection to do it. Everything is ok when i do testing my code on ios4.3. But when i'm launch my app on ios5.0, i found the connection:didreceiveData haven't been called whatever what i did. otherelse functions is called normally, just like connectionDidFinishLoading in ios4.3 and connectionDidFinishDownloading in ios5.0. so u guys, who can help me, thanks advanced! -(void)load { if(isDownloading){ return; } if(conn != nil){

Test NSURLConnection failure

可紊 提交于 2019-12-10 11:02:39
问题 How can you test a failure of NSURLConnection? Also, how do you tell if it failed due to airplane mode or WiFi being turned off? In my tests, while the alert pops up telling the user they need to turn on WiFi, if they ignore it my App just sits there and spins waiting for a response. 回答1: If your connection's delegate is self, you can something like this: self.myConnection = [[[NSURLConnection alloc] initWithRequest:urlRequest delegate:self] autorelease]; - (void)connection:(NSURLConnection *

NSUrlRequest from curl for stripe

被刻印的时光 ゝ 提交于 2019-12-10 10:04:06
问题 I need to make a http post request using the following instructions: curl https://api.stripe.com/v1/tokens \ -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \ -d "bank_account[country]=US" \ -d "bank_account[routing_number]=110000000" \ -d "bank_account[account_number]=000123456789" I have no idea how to go from curl to NSUrlrequest, especially the -u (user?) part. The stripe SDK has left this out from their SDK and has no example on their site. Thanks 回答1: EDIT:I created another answer specifically for

NSURLSession delegate methods not called

不问归期 提交于 2019-12-10 09:28:18
问题 I have created a very simple app to download a text file from my web server. I have this working perfectly with NSURLConnection, but am trying to migrate over to NSURLSession instead. The issue I am having is that none of the delegate methods are being called. My server is password protected so I need to use the basic http authentication to access the file, but when the didReceiveChallenge method is never called. The line of code [getFileTask resume] seems to have no effect on anything. My

Domain=NSURLErrorDomain Code=-1001 “The operation couldn’t be completed. (NSURLErrorDomain error -1001.)”

妖精的绣舞 提交于 2019-12-09 20:11:20
问题 my program is write for upload the picture from the cam,sample code below: #define WEBSERVICE_URL @"http://192.168.0.104/upload.php" - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissViewControllerAnimated:YES completion:^{ UIImage *selectedImage = [info objectForKey:UIImagePickerControllerOriginalImage]; NSData *imageData = UIImagePNGRepresentation(selectedImage); NSMutableURLRequest *request = [

When does NSURLConnection's initWithRequest return nil

喜你入骨 提交于 2019-12-09 14:12:39
问题 Does anyone know in which situations initializing a NSURLConnection returns nil instead of the created connection. The documentation says it's possible but fails to specify when this happens. The method/message in question: [[NSURLConnection alloc] initWithRequest:request delegate:self]; - According to the NSURLConnection Class Reference: Return Value: The URL connection for the URL request. Returns nil if a connection can't be initialized. The URL Loading System Programming Guide says the

NSURLConnection - Disable the authentication challenge response mechanism

十年热恋 提交于 2019-12-09 09:44:26
问题 SITUATION Using AFNetworking (NSURLConnection) to access my server API The API needs Basic Authentication with token as username The API returns HTTP 401 when token is invalid I set the Basic Authentication headers before any request If it returns 401, I retry like this: AFHTTPRequestOperation *requestOperation = [MyHTTPClient.sharedClient HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) { processSuccessBlock(operation, responseObject); }

How can I send multiple url request from a NSURLConnection delegate?

匆匆过客 提交于 2019-12-09 06:43:15
问题 This is the logical flow for my application: At first, when the view controller has finished loading, then a NSURLConnection request can start its execution The response consists in xml data After parsing that xml I need to send another NSURLConnection request. After sending the second request, if the response is ok, I receive other xml data After parsing the second xml, I have to check some issues between first and second xml data. So, is it possible to send multiple request? How? I do not

The connection to service named com.apple.nsurlstorage-cache was invalidated

余生长醉 提交于 2019-12-09 03:30:32
问题 I'm creating a custom keyboard for iOS8, and I'm having a tough time figuring out some issues with NSURLConnection. I'm using the sendAsynchronousRequest: method like this: [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) { NSLog(@"recieved asynchronous response"); if (!connectionError) { [self connection:nil didReceiveData:data]; [self connectionDidFinishLoading:nil]; }

How can I wait for a NSURLConnection delegate to finish before executing the next statement?

不羁岁月 提交于 2019-12-09 03:25:02
问题 This has been a hard one to search. I found a similar question, iOS 5 Wait for delegate to finish before populating a table?, but the accepted answer was 'Refresh the table view,' and that does not help me. The other results I found tended to be in c#. I have an app that streams from iPhone to Wowza servers. When the user hits record, I generate a unique device id, then send it to a PHP script on the server that returns a JSON document with configuration settings (which includes the rtmp dump