create your own file name:
cfuuidref uuid = cfuuidcreate(null); cfstringref uuidstring = cfuuidcreatestring(null, uuid); cfrelease(uuid); nsstring *uniquefilename = [nsstring stringwithformat:@"%@%@", prefixstring, (nsstring *)uuidstring]; cfrelease(uuidstring);
a simpler alternative proposed by @darrinm in the comments:
nsstring *prefixstring = @"myfilename"; nsstring *guid = [[nsprocessinfo processinfo] globallyuniquestring] ; nsstring *uniquefilename = [nsstring stringwithformat:@"%@_%@", prefixstring, guid]; nslog(@"uniquefilename: '%@'", uniquefilename);
nslog output: uniquefilename: 'myfilename_680e77f2-20b8-444e-875b-11453b06606e-688-00000145b460af51'
note: ios6 introduced the nsuuid class which can be used in place of cfuuid.
nsstring *guid = [[nsuuid new] uuidstring];
create your own file name:
a simpler alternative proposed by @darrinm in the comments:
nslog output:
uniquefilename: 'myfilename_680e77f2-20b8-444e-875b-11453b06606e-688-00000145b460af51'
note: ios6 introduced the nsuuid class which can be used in place of cfuuid.