• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [iPhone] How to create a unique string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: [iPhone] How to create a unique string
      • From: Jonathan del Strother <email@hidden>
References: 
 >[iPhone] How to create a unique string (From: Tharindu Madushanka <email@hidden>)

  • Prev by Date: [iPhone] How to create a unique string
  • Next by Date: Re: [iPhone] How to create a unique string
  • Previous by thread: [iPhone] How to create a unique string
  • Next by thread: Re: [iPhone] How to create a unique string
  • Index(es):
    • Date
    • Thread