• 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: 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

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

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