我想在我的iPhone应用程序(我放入我的proyect)中替换所有旧的PDF以获取新的PDF,但我不能这样做。在某些情况下,应用程序仍然显示我的旧文件....可能是什么问题?我需要通过代码从iPhone内存中删除旧的以进行更新......
非常感谢任何帮助
NSString *appFolderPath = [[NSBundle mainBundle] resourcePath];
NSArray *contenido = [fileManager contentsOfDirectoryAtPath: appFolderPath error:nil];
NSEnumerator *e = [contenido objectEnumerator];
NSString *filename;
while ((filename = [e nextObject])) {
if ([[filename pathExtension] isEqualToString:@"pdf"]) {
//NSLog(@"Archivo %@", filename); me da el nomber SCEL VAC.pdf
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSString *myFilePath = [documentsDirectoryPath stringByAppendingPathComponent:filename];
//NSLog(@"path archivo %@", myFilePath);// me da dentro de documents
if ([fileManager fileExistsAtPath:myFilePath] == NO) {
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:filename ofType:nil];
bool success = [fileManager copyItemAtPath:resourcePath toPath:myFilePath error:&error1];
if (success){
NSLog(@"instalado %@", myFilePath);
}
}else if ([fileManager fileExistsAtPath:myFilePath] == YES)
{
bool success = [fileManager removeItemAtPath:myFilePath error:&error1];
if (success){
NSLog(@"borrado %@", myFilePath);
}
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:filename ofType:nil];
bool success2 = [fileManager copyItemAtPath:resourcePath toPath:myFilePath error:&error1];
if (success2){
NSLog(@"copiado %@", myFilePath);
}
}
}
}
答案 0 :(得分:0)
您无法更改主要包中的任何文件。
因此,在您的更新中,您应该从项目中删除旧的PDFS,然后它们在主要包中不再可用。