3
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]

Keshava GN
  • 4,195
  • 2
  • 36
  • 47
Kishore Reddy
  • 886
  • 3
  • 11
  • 19
  • 1
    This is not exactly a duplicate... The other question was asking for system time in milliseconds, this is asking for the formatter format. – Morkrom May 14 '14 at 17:37

2 Answers2

9

You can set a date format like

[dateFormatter setDateFormat:@"yyyy-MM-dd-HH:mm:ss:SSS"];

"SSS" is for milliseconds.

Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
5

just do like this [[NSDate date] timeIntervalSince1970];

nsgulliver
  • 12,655
  • 23
  • 43
  • 64