リソースをDocumentsフォルダーに保存しているため、アプリケーションがAppleから拒否されました。Documentsフォルダは自動的にiCloudeに同期されるため、ユーザーが生成したデータのみをDocumentsの下に保存する必要があります。すべてのアプリケーションデータは、アプリケーションバンドルの下に配置する必要があります。
プロジェクト全体で次の方法を使用します
- (NSString *)filePath:(NSString *)fileName {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:fileName];
return path;
}
たとえば、次の行は、ドキュメントフォルダの下にあるリソースを解凍します。
[SSZipArchive unzipFileAtPath:zipFileName toDestination:[self filePath:@ ""]];
これらのファイルとリソースフォルダの画像をアプリケーションバンドルに移動してアクセスするにはどうすればよいですか?
[編集]
- (NSString *)filePath:(NSString *)fileName {
NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/DoNotBackUp"];
if (![[NSFileManager defaultManager] fileExistsAtPath:path]) {
[[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:NO attributes:nil error:nil];
// Set do not backup attribute to whole folder
if (iOS5) {
BOOL success = [self addSkipBackupAttributeToItemAtURL:path];
if (success)
NSLog(@"Marked %@", path);
else
NSLog(@"Can't marked %@", path);
}
}
path = [path stringByAppendingPathComponent:fileName];
return path;
}
/*
set the document files attribute to marked "do not backup"
*/
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSString *)path
{
const char* filePath = [path fileSystemRepresentation];
const char* attrName = "com.apple.MobileBackup";
u_int8_t attrValue = 1;
int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
return result == 0;
}
iOS5がBOOL変数である場合:
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
iOS5 = NO;
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"5.0.1"))
iOS5 = YES;
ありがとう。