nsurlconnection

How to insert header info into MPMoviePlayerController url?

匆匆过客 提交于 2019-11-29 02:45:07
I need to implement video streaming service with http protocol. I know how to set url into MPMoviePlayerController, and how to set headerField into NSMutableURLRequest, but I have no idea how to combine them. I implement like below code, but not working, and I assume because there is no file info in the binary data. - (void) openUrl { NSMutableURLRequest *reqURL = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:@"http://111.222.33.44/MOV/2013/4/123123123"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0]; [reqURL setHTTPMethod:@"GET"]; [reqURL setValue:@"Mozilla/4

NSURLConnection delegation and threading - iPhone

醉酒当歌 提交于 2019-11-29 02:40:14
I have a class that updates two .plist files in the app documents directory via an NSURLConnection. The class acts as its own delegate for NSURLConnection. It works properly when I ask for a single file, but fails when I try to update two files. Does it look like I should start a new thread for each of the getNewDatabase messages? - (void)getAllNewDatabases { [self performSelectorOnMainThread:@selector(getNewDatabase:) withObject:@"file1" waitUntilDone:YES]; [self performSelectorOnMainThread:@selector(getNewDatabase:) withObject:@"file2" waitUntilDone:YES]; } - (BOOL)getNewDatabase:(NSString *

Why should I prefer ASIHTTPRequest over NSURLConnection for downloading files from the web?

独自空忆成欢 提交于 2019-11-29 02:27:09
问题 I've seen a couple of times people using ASIHTTPRequest to download files. Now I wonder why? What are the core benefits over NSURLConnection? 回答1: There are several reasons. In my mind these are the major ones: ASIHTTPRequest allows to specify a delegate for each request (vs. one delegate for a whole NSURLConnection ); this is useful because each request has in principle a different processing once you get the data you were waiting for; ASIHTTPRequest supports a caching mechanism that make

What are alternatives to NSURLConnection for chunked transfer encoding

百般思念 提交于 2019-11-29 02:01:52
I've checked for other questions relevant to this, but the only answer is "Use ASIHTTPRequest " as this is no longer being developed I wanted to ask what alternatives people are using, whilst working on our SDK I came across a lot of strange behaviour in NSURLConnection when receiving data from the server. We tracked it down to the fact that NSURLConnection doesn't deal well with responses in chunked-encoding. Or at least so we read in this question here NSURLConnection and "chunked" transfer-coding Some developers we were talking to say it gets better in iOS 5, we need to make sure that our

MBProgressHUD with NSURLConnection

人走茶凉 提交于 2019-11-29 00:43:09
I was trying to use MBProgressHUD with NSURLConnection. The example in Demo project of MBProgressHUD reports: - (IBAction)showURL:(id)sender { NSURL *URL = [NSURL URLWithString:@"https://github.com/matej/MBProgressHUD/zipball/master"]; NSURLRequest *request = [NSURLRequest requestWithURL:URL]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [connection start]; [connection release]; HUD = [[MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES] retain]; HUD.delegate = self; } - (void)connection:(NSURLConnection *)connection

NSURLConnection doesn't call delegate methods

被刻印的时光 ゝ 提交于 2019-11-28 23:23:52
I saw similar questions here, but I couldn't find solution to my problem. I have a simple NSURLConnection in main thread (At least I didn't create any other threads), but my delegate methods aren't get called [[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease]; and no methods called, e.g. - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { NSLog(@"didReceiveResponse"); } self is also a delegate for NSXMLParser, but I think it should not be a problem, as I have this working in my other class in the same project. I checked

How to use NSURLConnection completionHandler with swift

拈花ヽ惹草 提交于 2019-11-28 22:50:46
问题 Does anybody know how handlers (blocks) work in swift? I am trying to get this code running but i can't find any documentation of the right syntax for the completionHandler. let url:NSURL = NSURL(string:"some url") let request:NSURLRequest = NSURLRequest(URL:url) let queue:NSOperationQueue = NSOperationQueue() NSURLConnection.sendAsynchronousRequest(request:request, queue:queue, completionHandler handler:((NSURLResponse!, NSData!, NSError!) -> Void)!) 回答1: Like this: NSURLConnection

Retrieve HTTPResponse/HTTPRequest status codes in iOS?

末鹿安然 提交于 2019-11-28 21:02:06
问题 I need to check and evaluate the HTTP Status Codes in my iPhone app. I've got an NSURLRequest object and an NSURLConnection that successfully (I think) connect to the site: // create the request NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; // create the connection with the request // and start loading the data NSURLConnection *theConnection=[[NSURLConnection alloc]

UIImage to be displayed progressively from server

烂漫一生 提交于 2019-11-28 20:37:59
I have been trying to display large image from server, but I have to display it progressively. I used subclass of UIView and in that I have taken UIImage object, in which I used NSURLConnection and its delegate methods, I also used - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data; in which I am appending data and converting it to UIImage object, and drawing rect using the drawInRect: method of UIImage . Everything is working fine, but the problem is, when image is being drawn on context, I cannot click anywhere else on screen until entire image is being drawn on

Getting Image from URL/server [duplicate]

橙三吉。 提交于 2019-11-28 18:28:18
This question already has an answer here: iOS download and save image inside app 10 answers I'm fairly new to iPhone development and trying to fetch 'Images from Server' in my application. I'm using the following method to do this: - (UIImage *)imageFromURLString:(NSString *)urlString { NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; [request setHTTPMethod:@"GET"]; NSURLResponse *response = nil; NSError *error = nil; NSData *result = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error: