Created
December 22, 2012 03:43
-
-
Save kristate/4357393 to your computer and use it in GitHub Desktop.
Unique Download Filename
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString* fname = [target lastPathComponent]; | |
NSString* fnameNoExt = [fname stringByDeletingPathExtension]; | |
NSString* extension = [fname pathExtension]; | |
int fileIndex = 1; | |
while ([[NSFileManager defaultManager] fileExistsAtPath: [folder stringByAppendingPathComponent:fname]]) | |
{ | |
//NSLog(@"FNAME : %@",fname); | |
fname = [NSString stringWithFormat:@"%@ (%d).%@", fnameNoExt, fileIndex, extension]; | |
//NSLog(@"Setting filename to :: %@",fname); | |
fileIndex++; | |
} | |
target = [folder stringByAppendingPathComponent:fname]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment