开发者

iPhone: How to download a raw .config file via program?

I am trying to download a xyz.config file which is created using iPhone Configuration utlity, via code.

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.
}

Then, didReceiveData, didReceiveResponse are written. Finally,

- (void)connectionDidFinishLoading:(NSURLConnection *)connection

{

NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]);

NSString *responseString = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];

NSLog(@"Response :  %@", responseString );

// release the connection, and the data object
[receivedData release];
[connection release];

}

With the above code, i'm getting response as string of the complete configuration file. But my Aim to download this file as raw data, which will automatically launch device profile to ask for installing this profile. NOTE: I am able to provide the same URL in Safari browser on the device, and download the raw file directly to install it on the device. I don't want to use Safari browser to download it, it should be done via my communication code.

I also tried with ASIHTTPRequest like below, but unable to download that file directly from the URL via this code as well.

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setRequestMethod:@"GET"];
[request startSynchronous];

Please help!

Thank you.


The Mobile Safari browser app on the iOS has a lot more freedom than your app. Case in point, on the latest iOS 4.3, Mobile Safari has the Nitro JavaScript engine which boost 2x performance increase. But the UIWebView which is available to your app doesn't have that engine. Your app is in a sandbox, therefore, you cannot write outside of that box.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜