NSURL *url=[NSURL URLWithString:@"/Documents/file.mp3"];
NSURLRequest *req=[NSURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:120];
NSURLConnection *con=[[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:YES];
if(con){
receivedData = [NSMutableData data] ;
} else {
}
利用 :
NSURLConnectionDataDelegate,NSURLConnectionDelegate
方法
喜欢 :
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)d{}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {}