【发布时间】:2011-04-08 20:08:55
【问题描述】:
我的 iPhone 应用程序出现非常奇怪的问题。我们有一款 App 已获批准并在 App Store 上销售。它包含下载一些数据库更新的功能。更新通过 HTTP 以 ZIP 形式提供。 问题是我无法保存下载的 ZIP,因为我收到“无法完成操作。不允许操作”错误。
但是:这种情况发生在十分之二的手机上。如果手机无法保存文件,它根本无法保存。如果我从商店重新下载该应用程序,它不会改变它。但是那些能够保存 ZIP 的手机总是有能力的。所有手机都运行相同的 iOS 版本,而且都是 iPhone 4。这真的让我抓狂。
如果我启动 XCode,一部手机在调试时没有出现错误,另一部给出了错误。他们总是给予。
代码如下:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[activeResponse release];
[theConnection release];
NSLog(@"%d", [receivedData length]);
NSString *s = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding];
NSLog(@"%@", s);
[s release];
[theRequest release];
NSString *path = [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath], @"temp.zip"];
NSLog(path);
NSError * error;
if ([receivedData writeToFile:path options:NSDataWritingAtomic error:&error])
NSLog(@"Success");
else
NSLog(@"Error");
if (error)
NSLog([error description]);
有什么想法吗?
【问题讨论】: