次のコードでは、文字列の代わりに変数を割り当てたいと思います。まず、ディレクトリのコンマ区切りリストから配列を作成しています。次に、配列内の各ディレクトリについて、存在しない場合は作成します。
@ "templates / standard1 / css"ではなく、配列からディレクトリを割り当てるにはどうすればよいですか。sに置き換えようとしましたが、うまくいきませんでした。をNSlogできますが、ディレクトリが作成されていないようです。
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *theString = @"templates, templates/standard1, templates/standard1/css, themes, themes/plain, themes/plain/384";
NSArray *items = [theString componentsSeparatedByString:@","];
for (NSString *s in items) {
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"templates/standard1/css"];
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath]) {
// Directory does not exist so create it
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:YES attributes:nil error:nil];
}
}
どんな助けもいただければ幸いです:)