在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