nsurlconnection

iPhone SDK: How do you download video files to the Document Directory and then play them?

限于喜欢 提交于 2019-11-27 07:01:45
I've been fooling around with code for ages on this one, I would be very grateful if someone could provide a code sample that downloaded this file from a server http://www.archive.org/download/june_high/june_high_512kb.mp4 , (By the way it's not actually this file, it's just a perfect example for anyone trying to help me) and then play it from the documents directory. I know it seems lazy of me to ask this but I have tried so many different variations of NSURLConnection that it's driving me crazy. Also, if I did manage to get the video file downloaded would I be correct in assuming this code

iOS: How can i receive HTTP 401 instead of -1012 NSURLErrorUserCancelledAuthentication

狂风中的少年 提交于 2019-11-27 06:49:00
I have a problem similar to the one described in the link below. NSHTTPURLResponse statusCode is returning zero when it should be 401 I use [NSURLConnection sendSynchronousRequest:returningResponse:error:] to get data from a server. When NSURLConnection receives the HTTP Code 401, it does not return anything but an error object with code -1012 from the NSURLErrorDomain. -1012 corresponds to NSURLErrorUserCancelledAuthentication . Since I have to parse the HTTP Header I need to get the original error and not what NSURLConnection made out of it. Is there a way to receive the original 401 http

NSURLConnection didReceiveData not called

a 夏天 提交于 2019-11-27 06:13:35
问题 I've read through tons of messages saying the same thing all over again : when you use a NSURLConnection, delegate methods are not called . I understand that Apple's doc are incomplete and reference deprecated methods, which is a shame, but I can't seem to find a solution. Code for the request is there : // Create request NSURL *urlObj = [NSURL URLWithString:url]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:urlObj cachePolicy:NSURLRequestReloadIgnoringCacheData

Object-c/iOS :How to use ASynchronous to get a data from URL?

痴心易碎 提交于 2019-11-27 05:46:11
问题 My friend saw my code, a part is get a plist data from URL And he told me not to use Synchronous,Use ASynchronous But I don't know how to do ASynchronous in simple way This is the code I use in my program NSURL *theURL = [[NSURL alloc]initWithString:@"http://someurllink.php" ]; NSURLRequest *theRequest=[NSURLRequest requestWithURL:theURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; NSData *returnData = [NSURLConnection sendSynchronousRequest:theRequest

Cocoa: Checks required for multiple asynchronous NSURLConnections using same delegate functions?

半腔热情 提交于 2019-11-27 05:13:32
问题 This is with reference to the StackOverflow question Managing multiple asynchronous NSURLConnection connections I have multiple asynchronous HTTP requests being made at the same time. All these use the same NSURLConnection delegate functions. (The receivedData object is different for each connection as specified in the other question above. In the delegate, I parse the receivedDate object, and do additional operations on those parsed strings) Everything works fine for me so far, but I'm not

Ignoring certificate errors with NSURLConnection

血红的双手。 提交于 2019-11-27 04:37:53
I am getting this error The certificate for this server is invalid. You might be connecting to a server that is pretending to be "server addres goes here" which could put your confidential information at risk." I am using this method: [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; How can I fix this? I tried this code: NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; but then I get EXC_BAD_ACCESS in the didReceiveResponse method. You could simply ignore the invalid certificate if you are not sending any

How to download a large file with the iPhone SDK and avoid memory usage issues?

巧了我就是萌 提交于 2019-11-27 04:12:20
问题 I'm using the NSURLConnection class to download a large file in my iPhone application, but it crashes every so often because it's using too much memory. I'm doing the usual NSURLConnection usage, to append the received data to a NSMutableData object. - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [self.fileData appendData:data]; } Then after I finish downloading the whole file, I save it to a local temporary file, and read it as a mapped file like this: -

NSURLConnection delegate method

◇◆丶佛笑我妖孽 提交于 2019-11-27 03:24:57
问题 I am having a hard time to find any examples for NSURLConnection delegate method implementations. I want to send data with a HTTP post with a button click. Not sure how to make a "submitting" screen and "submitted". (I know how to use spinner and will use them) I am using this code under a botton click action, but unable to use any delegate stuff. Not sure how to implement them with my current set up. NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL

How to identify WHICH NSURLConnection did finish loading when there are multiple ones?

自闭症网瘾萝莉.ら 提交于 2019-11-27 03:06:02
问题 Multiple NSURLConnections being started (in a single UIViewController) to gather different kinds of data. When they return (-connectionDidFinishLoading) I wanna do stuff with the data, depending on the type of data that has arrived. But one prob, HOW DO I KNOW WHICH NSURLConnection returned? I need to know so I can take action specific to the type of data that came. (Eg. display a twitter update if it was the twitter xml data)(Eg. display an image if it was a photo) How do people usually

NSMutableURLRequest not obeying my timeoutInterval

假装没事ソ 提交于 2019-11-27 03:03:48
I'm POST'ing a small image, so i'd like the timeout interval to be short. If the image doesn't send in a few seconds, it's probably never going to send. For some unknown reason my NSURLConnection is never failing, no matter how short I set the timeoutInterval . // Create the URL request NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.tumblr.com/api/write"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:0.00000001]; /* Populate the request, this part works fine */ [NSURLConnection connectionWithRequest:request delegate