I am new to iphone development. I am developing one iphone application in which i am downloading files from server using php web service. So i am getting response as encoded bytes and i am decoding response and store it as a file in iphone.
It works good for small size files upto 2 MB. But for files more than that it takes a long time to download and decode.
Please any one tell me how to do it for large files..
Is there any quicker method available to downlo开发者_开发知识库ad large files from web service???
Try using
NSURLRequest* request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
And also implement the delegate methods
1. - (void)connection:(NSURLConnection *)theConnection didReceiveData:(NSData *)incrementalData;
2. - (void)connection: (NSURLConnection*) connection didReceiveResponse: (NSHTTPURLResponse*) response;
3. - (void) connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite;
Try using ASIHTTPRequest to download files. While I cannot say if it will make your downloads faster, it should certainly make it easier.
I would recommend using ASIHTTPRequest library. It just download the file background and you can enable the progress bar to show to the user. but be careful you app may reject cause you are not supposed to download large file over WAN
(Apple advised to not exceed 4.5 meg of data per 5 minutes of activity. You can test your app’s usage by going into your iPhone settings, choosing the General->Usage menu and clearing the stats. Then run your app for 5 minutes, return to this screen and see what the stats say. Also, to get the most accurate numbers, you should turn off any other network activity on your phone while you run the test (such as Email or MobileMe updates).
Apple has quietly doubled iPhone 3G over-the-air download limits from the meager 10MB to 20MB, which includes all apps, music, podcasts and more
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDownloadDestinationPath:@"/Users/ben/Desktop/my_file.txt"];
ASIHTTPRequest
精彩评论