NSURLConnection的方法说明

初始化一个NSURLConnection NSURLConnection *registerConnection = [NSURLConnection connectionWithRequest:[NSURLRequest requestWithURL:[ NSURL URLWithString:@"http://www.baidu.com" ]] delegate:self]; //我们可以从http返回的response中拿到一些连接的信息。这里我拿到了要下载的数据的大小,保存在"Content-Length"的字段中 - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response; //接受返回的data NSMutableData *receiveData ;[receiveData appendData:data]; - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data //连接结束,一般再这里处理data - (void)connectionDidFinishLoading:(NSURLConnection *)connection //定义连接出错的情况的处理 - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;

你可能感兴趣的:(urlconnection)