Ale*_*987 3 objective-c nsurlconnection ios mime-types
我想同步得到一个网址的Mime类型.我不想使用NSURLConnection.就像这样:
NSString*theMimeType = [self getMimeTypeFromURL:theURL];
有任何想法吗?
绝对没有理由不使用异步请求.
使用NSURLConnection委托方法.
NSString *url = ...;
NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
NSURLConnection *conn = [NSURLConnection connectionWithRequest:req delegate:self];
[conn start];
Run Code Online (Sandbox Code Playgroud)
在你的其他地方@implementation:
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
NSString *mime = [response MIMEType];
//do something with mime
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4962 次 |
| 最近记录: |