生成唯一的临时文件路径

发布于 2024-09-10 22:19:36 字数 193 浏览 1 评论 0原文

我想在 Objective-C 中生成唯一的文件路径。我查看了 NSTemporaryDirectory() 但我能得到的最接近的是 这个

I want to generate unique file paths in Objective-C. I looked at NSTemporaryDirectory() but the closest I could get was to this and this. But in the second one they create such a file. I do not want to create it, I just want an NSString for a unique writable path... I don't need paths to folders, just files. How is this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月竹挽风 2024-09-17 22:19:36

您可以使用当前系统日期和时间创建文件名 ([[NSCalendarDate calendarDate] descriptionWithCalendarFormat:@"%m%d%Y%H%M%S%F"]) ....包括偶数毫秒...使用返回字符串作为唯一文件名...

阅读有关日期格式的更多信息 -> http://developer.apple.com/ iphone/library/documentation/cocoa/Conceptual/DatesAndTimes/Articles/LegacyNSCalendarDate.html

You can create file name using present system date and time ([[NSCalendarDate calendarDate] descriptionWithCalendarFormat:@"%m%d%Y%H%M%S%F"]) .... this include even milliseconds ... use returning string as unique file name ....

Read more about date formates -> http://developer.apple.com/iphone/library/documentation/cocoa/Conceptual/DatesAndTimes/Articles/LegacyNSCalendarDate.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文