I create a directory in the documents directory with the string @”My Folder” by pressing a button.
But if this directory already exist I want it to be named @”My Folder 1″ and if this exists then @”My Folder 2″ and so on..
How can I achieve this?
I test whether the directory already exists with this
if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
[[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:nil];
else {
}
This should work for what you need.