0
我想在我的iPhone应用程序(我放入我的专业版)中替换所有旧版PDF,但我无法做到。在某些情况下,应用程序仍然显示我旧的文件....可能是什么问题?我需要通过代码来删除iPhone内存旧的做更新...在更新中删除iPhone APP中的旧版PDF
任何帮助非常感谢
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);
}
}
}
}
谢谢...我已经从我的项目中删除旧的PDF,但在手机中,他们仍然存在...我需要知道如何通过代码删除它们... –
如果他们在主包你不能删除它们,你应该能够删除的文件目录中的那些包。 – rckoenes