在iphone里写文件,需要生成唯一的文件名。

一种方法事采用UUID

 

+ (NSString *)GetUUID
{
  CFUUIDRef theUUID = CFUUIDCreate(NULL);
  CFStringRef string = CFUUIDCreateString(NULL, theUUID);
  CFRelease(theUUID);
  return [(NSString *)string autorelease];
}

来源 http://stackoverflow.com/questions/427180/how-to-create-a-guid-uuid-using-the-iphone-sdk

 

另一种方法用具体的时间生成文件名

 

[[NSCalendarDate calendarDate] descriptionWithCalendarFormat:@"%m%d%Y%H%M%S%F"]

http://developer.apple.com/iphone/library/documentation/cocoa/Conceptual/DatesAndTimes/Articles/LegacyNSCalendarDate.html

来源:http://stackoverflow.com/questions/3298022/generate-unique-temporary-file-paths

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
  • 2022-02-10
  • 2021-12-17
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2021-11-23
相关资源
相似解决方案