【问题标题】:How to create folder programmatically and move installed apps into this folder如何以编程方式创建文件夹并将已安装的应用程序移动到此文件夹中
【发布时间】:2014-03-21 05:13:32
【问题描述】:

我有两个单独的应用程序。当我将它们安装在设备上时,它们显示为普通应用程序。但是当我第一次运行应用程序时,我想创建一个文件夹并将这两个应用程序移动到这个文件夹中。我知道当我们通过拖放将第一个应用程序移动到其他应用程序时,我们可以做到这一点。但我想自动完成。

【问题讨论】:

    标签: ios ios5


    【解决方案1】:
    NSError *ferr;
                NSString *filename = [NSString stringWithFormat:@"RecordFile_%@.txt",donation_rec_id_str];
                NSString *destination_path = [self DocumentDirectory];
                destination_path = [destination_path stringByAppendingString:@"/Record_Backup"];
    
                //Create folder
                if (![[NSFileManager defaultManager] fileExistsAtPath:destination_path])
                    [[NSFileManager defaultManager] createDirectoryAtPath:destination_path withIntermediateDirectories:NO attributes:nil error:&ferr];
    
                destination_path = [destination_path stringByAppendingPathComponent:filename];
                NSLog(@"FULL PATH:%@",destination_path);
    
                //MOVE/RENAME FILE
                if ( [[NSFileManager defaultManager] isReadableFileAtPath:source_filepath] ){
                    [[NSFileManager defaultManager] copyItemAtPath:source_filepath toPath:destination_path error:NULL];
                }
    

    【讨论】:

    • 我可能错了,但这会在应用程序的 Documents 目录中创建一个文件夹。据我了解,他要求的是如何将应用程序图标分组到主屏幕上的文件夹中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-09
    • 1970-01-01
    • 2020-02-21
    相关资源
    最近更新 更多