繁体   English   中英

在更新中从iPhone APP删除旧的PDF

[英]Delete OLDs PDF from iPhone APP in an update

我想用我的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);
                }
            }

        }
    }

您不能将主捆绑包中的任何文件更改为只读。

因此,在更新中,应从项目中删除旧的PDF,然后在主捆绑包中不再可用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM