【问题标题】:iOS - Making documents uneditable using iTunes file shareiOS - 使用 iTunes 文件共享使文档不可编辑
【发布时间】:2011-11-08 01:26:47
【问题描述】:

我在我的应用程序中使用 iTunes 文件共享。我的应用程序提供了几个可以使用 iTunes 文件共享传输的文件。但是目前用户可以删除,重命名(基本上对我的应用程序中可共享的内容做任何事情) 我想知道如何使用户没有这些权限,我想要它所以他们所能做的就是将文件传输过来。

这是代码,非常感谢任何帮助

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    NSArray *names = [NSArray arrayWithObjects: @"test.gif", @"test1.gif", nil];
    for (NSString *fileName in names)
    {
        NSFileManager *fileManager = [NSFileManager defaultManager];
        NSError *error;
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *documentDBFolderPath = [documentsDirectory stringByAppendingPathComponent:fileName];

        if (![fileManager fileExistsAtPath:documentDBFolderPath])
        {
            NSString *resourceDBFolderPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:fileName];
            [fileManager copyItemAtPath:resourceDBFolderPath toPath:documentDBFolderPath error:&error];
        }
    }
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    self.window.rootViewController = self.viewController;



    [self.window makeKeyAndVisible];
    return YES;
}

【问题讨论】:

    标签: iphone objective-c ios xcode cocoa-touch


    【解决方案1】:

    每次运行您的应用时,将所有新文件从共享目录移动(复制和删除)到非共享目录。

    【讨论】:

      猜你喜欢
      • 2011-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-04
      • 1970-01-01
      • 1970-01-01
      • 2011-07-22
      • 1970-01-01
      相关资源
      最近更新 更多