在我的 iPad 中写入文件时出现此错误。但是相同的应用程序在模拟器中运行良好。我在这里附上代码。
NSString *filepath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:doc.contentStreamFileName];
NSFileManager *fMngr = [NSFileManager defaultManager];
if ([fMngr fileExistsAtPath:filepath]) {
NSLog(@"File already available");
CMISExtensionElement *elem = [doc.properties.extensions objectAtIndex:0];
NSString *description = [self crop:elem.description];
[self loadImage:doc.contentStreamFileName desc:description];
}
else{
[doc downloadContentToFile:filepath completionBlock:^(NSError *error){
if (nil == error) {
NSLog(@"successful");
}
else
{
UIAlertView* alert = [[UIAlertView alloc]initWithTitle:@"Error retriving content" message:[NSString stringWithFormat:@"Error code: %d",error.code] delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
}
}progressBlock:^(unsigned long long bytesDownloaded, unsigned long long bytesTotal){
if (bytesTotal == bytesDownloaded) {
CMISExtensionElement *elem = [doc.properties.extensions objectAtIndex:0];
NSString *description = [self crop:elem.description];
[self loadImage:doc.contentStreamFileName desc:description];
}
}];
}