У меня есть файл, которым я хочу поделиться.'hello.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];
}
}
}