我有一个文件想要共享。 '你好.mp3' 目前,如果文件位于应用程序中,则代码会启用文件共享。 我希望我能够通过 http 来做到这一点。因此,通过链接而不是应用程序中的声音共享文件。我想这样做是因为它可以为用户节省内存。
这是当前的代码。如果文件位于应用程序中,则代码允许文件共享。我想要它,以便用户可以从 http 服务器“下载”声音,例如 http://test.com/hello.mp3
谢谢
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSArray *names = [NSArray arrayWithObjects: @"hello.mp3",
@"hi.mp3", 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];
}
}
}
最佳答案
我可能是错的,但这可能是不被允许的。在指南中:
2.7 以任何方式或形式下载代码的应用程序都将被拒绝。
虽然音频文件可能不是“代码”,但如果它在应用程序中使用,也许作为语言翻译项目等...我认为它会被拒绝...不过我的 2 美分值得。
关于iphone - iTunes 文件共享。但通过http 共享? iOS系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8057496/