Iphone 如何将时间戳添加到我的文件路径?

Iphone 如何将时间戳添加到我的文件路径?,iphone,objective-c,timestamp,download,Iphone,Objective C,Timestamp,Download,我有一个到下载文件夹的静态文件路径,文件下载很好,但当我下载一个新文件时,旧文件会被新文件替换。我想是因为静态路径。我如何在代码中添加一个时间戳,以便在每次进行新下载时,旧的不会被替换?或者甚至可以从实际数组中为下载文件提供“原始”文件名 这是我的下载代码: -(void) Savefile { [self.downloadfile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) { if (er

我有一个到下载文件夹的静态文件路径,文件下载很好,但当我下载一个新文件时,旧文件会被新文件替换。我想是因为静态路径。我如何在代码中添加一个时间戳,以便在每次进行新下载时,旧的不会被替换?或者甚至可以从实际数组中为下载文件提供“原始”文件名

这是我的下载代码:

-(void) Savefile {

    [self.downloadfile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
        if (error)  {

            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Wooopss!" message:@"Download failed. Try Again..." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
        }
        else if (data) {


            [data writeToFile:@"/Users/Danny/Desktop/PDFFile/hello.pdf" atomically:NO ];



            NSLog(@"Downloading file...");

            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Downloading" message:@"File is being downloaded..." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
        }
    }];

}
这将为您提供以下信息:

/Users/Danny/Desktop/PDFFile/hello_032620144401.pdf
不完全确定你所说的是什么意思:

或者甚至可以给下载文件提供“原始”文件名 实际阵列


谢谢,我试试看。哦,我的意思是原始文件名,就像我解析时数据库中的文件名一样。我正在从那里保存这些文件。想出了“从日期起选择器字符串没有已知的类”让它工作了!多谢了,老兄,这件事我已经耽搁了一段时间了。这些东西还是新的
/Users/Danny/Desktop/PDFFile/hello_032620144401.pdf