Я могу загрузить и сохранить двоичный файл в папке "Документы" с настраиваемым именем отлично.
Если я просто изменил URL-адрес в папку "Поддержка приложений" вместо папки "Документы", он не сможет записать на этот URL-адрес, что его не существует.
Здесь код построения URL:
- ( NSURL * ) getSaveFolder
{
NSURL * appSupportDir = nil;
NSURL * appDirectory = nil;
NSArray * possibleURLs = [[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSAllDomainsMask];
if ( [possibleURLs count] >= 1 )
{
appSupportDir = [possibleURLs objectAtIndex:0];
}
if ( appSupportDir != nil)
{
NSString * appBundleID = [[NSBundle mainBundle] bundleIdentifier];
appDirectory = [appSupportDir URLByAppendingPathComponent:appBundleID];
}
return appSupportDir;
}
Здесь сохраненный код:
- ( void ) writeOutDataToFile:( NSData * )data
{
NSURL * finalURL = [self.rootPathURL URLByAppendingPathComponent:self.aFileName];
[data writeToURL:finalURL atomically:YES];
}
Если я изменил NSArray на:
NSArray * possibleURLs = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];
тогда он сохраняет штраф.
Я читал файлы Apple Docs on File и не могу исправить это - что мне не хватает?