코드를 통해 iPhone Configuration utlity를 사용하여 만든 xyz.config 파일을 다운로드하려고합니다.iPhone : 프로그램을 통해 raw .config 파일을 다운로드하는 방법?
NSString *urlString = @"http://xxxxx:xxx/ms/servlet/ConfigServer?userid=xxx&pwd=xxx&emailid=xxxxx";
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
receivedData = [[NSMutableData data] retain];
} else {
// Inform the user that the connection failed.
}
그런 다음, didReceiveData, didReceiveResponse가 기록됩니다. 마지막
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
는 {
NSLog은 (@ [receivedData 길이]! "성공 데이터 % d 바이트를 수신");
NSString *responseString = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
NSLog(@"Response : %@", responseString);
// release the connection, and the data object
[receivedData release];
[connection release];
} 위의 코드와
, 나는 전체 구성 파일의 문자열로 반응을 얻고있다. 그러나이 파일을 원시 데이터로 다운로드하려고합니다. 자동으로이 프로파일 설치를 요청하는 장치 프로파일을 실행합니다. 참고 : 장치의 Safari 브라우저에 동일한 URL을 제공하고 원시 파일을 직접 다운로드하여 장치에 설치할 수 있습니다. Safari 브라우저를 사용하여 다운로드하지 않으려는 경우, 통신 코드를 통해 수행해야합니다.
또한 아래와 같이 ASIHTTPRequest를 시도했지만이 코드를 통해 URL에서 해당 파일을 직접 다운로드 할 수 없습니다.
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setRequestMethod:@"GET"];
[request startSynchronous];
도와주세요!
감사합니다.
대단히 감사합니다. Safari를 사용하지 않고 내 프로그램을 통해 .config 파일을 설치할 수 있습니까? – Getsy