简体   繁体   中英

How to download zip file to iphone?

I'm trying to download a zip file. It returns 0 bytes for myURL1, this code works for a xml file which returns roughly 200000 bytes.

NSURL *myURL1 = [NSURL URLWithString:@"http://www.enginbodur.com/files/GetAccounts.zip"];
NSURL *myURL2 = [NSURL URLWithString:@"http://www.jjfoodservice.com/rss/productscatalogue.xml"];

NSData *myData = [NSData dataWithContentsOfURL:myURL];

Can someone show me how to download zip files from a url?

Thanks

This should work, but is inadvisable. Your code will block while the file downloads, very bad practice. Learn how to use NSURLConnection instead.

NSURLConnection would indeed be a better solution. also, might sound silly, have you tried it with the url all lowercase?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM