externa style.css 시트가있는 간단한 index.html을 다운로드하도록 NSURLRequest를 설정하려고하지만이 작업을 수행하는 방법을 잘 모르겠습니다. 내가 원하는 파일에 대한 요청입니다. 그러나 이것은 약간 달라야하며 제가하려고하는 것에 대한 좋은 예를 찾을 수 없습니다.여러 매개 변수가있는 NSURLRequest
이 내 코드는 지금까지 있습니다 :
#pragma mark - NSURLConnection methods
- (void)htmlRequest
{
// Create the request.
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.mywebsite.com/index.html"]
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
// Create the NSMutableData to hold the received data.
// receivedData is an instance variable declared elsewhere.
receivedData = [NSMutableData data];
} else {
// Inform the user that the connection failed.
NSLog(@"Connection Fail");
}
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
// This method is called when the server has determined that it
// has enough information to create the NSURLResponse.
// It can be called multiple times, for example in the case of a
// redirect, so each time we reset the data.
// receivedData is an instance variable declared elsewhere.
[receivedData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
// Append the new data to receivedData.
// receivedData is an instance variable declared elsewhere.
[receivedData appendData:data];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
// inform the developer of error type
}
// This method uses methodName to determin which Initalizer method to send the response data to in EngineResponses.m
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
// EngineResponses *engineResponses = [EngineResponses sharedManager];
// [engineResponses GetManufacturers:receivedData];
NSString *myString = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
NSLog(@"%@", myString);
}
당신은 그냥 직접 .. 내 요청을 포맷 그래서 내가 index.html을 등을 얻는 방법을 알고 싶습니다 index.html을 호출하고 볼 수 글쎄 style.css
어떤 도움을 주시면 대단히 감사하겠습니다.
내 무지를 용서하지만, 콜백 메소드는 무엇입니까? – HurkNburkS
이름이 connection으로 시작하는 메소드 : – CarmeloS
괜찮습니다. 그 다음에는 그들에 대해 더 알 필요가 있습니다. 콜백에서 distinguidh라고 말하면 요청이 끝날 때까지 요청을하는 방법이 있습니까? 돌아가서 파싱 한 데이터에 따라 새 파일을 자동으로 가져 오는 중입니까? – HurkNburkS