Reputation: 926
NSString *nameToSave = word;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSString *fromDateString=[dateFormatter stringFromDate:[NSDate date]];
[dateFormatter release];
nameToSave = [word stringByAppendingString:fromDateString];
nameToSave = [nameToSave stringByAppendingString:@".txt"];
NSLog(@"Server notes name .............>>>>>>!!!! %@",nameToSave);
for saving filenames i am using dateformatter, my problem is in the above code word is same for two files and it is run within one second then two file names are same. So the files are overriding.., i think with use of milliseconds i can solve my problem, But i don't know how to get current time in milliseconds. [ seconds/1000 or any arithmetic operations is not helpful for me..., because after applying arithmetic operation also we get same name]
Upvotes: 3
Views: 3365
Reputation: 539685
You can set a date format like
[dateFormatter setDateFormat:@"yyyy-MM-dd-HH:mm:ss:SSS"];
"SSS" is for milliseconds.
Upvotes: 9