Re: [iPhone] How to create a unique string
Re: [iPhone] How to create a unique string
- Subject: Re: [iPhone] How to create a unique string
- From: John Pannell <email@hidden>
- Date: Thu, 13 May 2010 07:00:54 -0600
Hi Tharindu-
In the past, I have used a UUID for this purpose. You could add the following method to a category on NSString to make it quite easy:
+ (NSString*) stringWithNewUUID
{
CFUUIDRef uuidObj = CFUUIDCreate(nil);
NSString *newUUID = (NSString*)CFUUIDCreateString(nil, uuidObj);
CFRelease(uuidObj);
return [newUUID autorelease];
}
Then, you could just call [NSString stringWithNewUUID] every time you needed a new unique string.
Hope this helps!
John
On May 13, 2010, at 6:48 AM, Tharindu Madushanka wrote:
> Hi,
>
> I want to generate a unique string every time i push a button. Can I create
> some string like that using a time stamp NSDate object may be.
>
> ex. e3df44646ngfd5454nrteter
>
> Its really useful to know about a small code segment or way to create a
> unique string in iPhone.
>
> Thank you and Kind Regards,
>
> Tharindu
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden