[英]The operation couldn’t be completed. Operation not permitted
Very strange problem with my iPhone App. 我的iPhone App非常奇怪的问题。 We have an App that has been approved and is in sales at the App Store.
我们有一个已经批准并在App Store销售的应用程序。 It contains a feature to download some database updates.
它包含下载某些数据库更新的功能。 The update comes in a ZIP via HTTP.
此更新通过HTTP以ZIP形式提供。 The problem is that I cannot save this downloaded ZIP because I get the "The operation couldn't be completed. Operation not permitted" error.
问题是我无法保存这个下载的ZIP,因为我得到“操作无法完成。操作不允许”错误。
BUT: this happens on 2 phones out of 10. If a phone cannot save the file it cannot do at all. 但是:这种情况发生在10个手机中。如果手机无法保存文件,则完全无法进行。 If I redownload the app from the store it does not change it.
如果我从商店重新下载应用程序,它不会更改它。 But those phones who are capable to save the ZIP are always capable.
但那些能够保存ZIP的手机总是有能力的。 All phones run the same iOS version and all of them are iPhone 4. This really drives me crazy.
所有手机都运行相同的iOS版本,所有手机都是iPhone 4.这真让我疯狂。
If I start XCode one phone gives no error in debug the other gives. 如果我启动XCode,一个手机在调试时没有给出错误,另一个给出。 And they always give.
他们总是给予。
Here is the code: 这是代码:
- (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]);
Any ideas, please? 请问有什么想法吗?
You are not allowed to write to the application bundle, I'm surprised it works on any of your devices. 您不能写入应用程序包,我很惊讶它适用于您的任何设备。 There are various places you can write, depending on what your purpose is:
根据您的目的,您可以编写各种地方:
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]
[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]
NSTemporaryDirectory()
NSTemporaryDirectory()
Also, BTW, it might be cleaner to use [directory stringByAppendingPathComponent:filename]
rather than [NSString stringWithFormat:@"%@/%@", directory, filename]
to construct paths. 另外,BTW,使用
[directory stringByAppendingPathComponent:filename]
而不是[NSString stringWithFormat:@"%@/%@", directory, filename]
来构造路径可能更清晰。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.