【发布时间】: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