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: Jonathan del Strother <email@hidden>
- Date: Thu, 13 May 2010 14:49:44 +0100
On 13 May 2010 14:00, John Pannell <email@hidden> wrote:
> 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
>
It might be simpler to just use [[NSProcessInfo processInfo]
globallyUniqueString]
-Jonathan
_______________________________________________
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