Reputation: 9457
I would like to get the Mime Type of a url synchronously. I don't want to use NSURLConnection. Just something like:
NSString *theMimeType = [self getMimeTypeFromURL:theURL];
Any ideas?
Upvotes: 3
Views: 5028
Reputation: 163228
There is absolutely no reason not to use asynchronous requests.
Use NSURLConnection
's delegate approach.
NSString *url = ...;
NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
NSURLConnection *conn = [NSURLConnection connectionWithRequest:req delegate:self];
[conn start];
Somewhere else in your @implementation
:
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
NSString *mime = [response MIMEType];
//do something with mime
}
Upvotes: 9