I would like to assign a variable instead of the string in my following code. First i am creating an array from comma separated list of directories. Next for each directory in the array, i want to create them, if they doesn't exist.
How do i assign the directory from the array rather than: @"templates/standard1/css" I have tried replacing it with s, but that didn't work out. I can NSlog the s, but it doesn't seem to create the directories.
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];
}
}
Any help would be appreciated :)