• 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: Seeding random() randomly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Seeding random() randomly


  • Subject: Re: Seeding random() randomly
  • From: Dave Keck <email@hidden>
  • Date: Thu, 26 May 2011 15:15:58 -1000

> I'm using random(), but every time I run my app I get the same sequence, despite having this code in my app delegate's -appDidFinishLaunching method. Clearly I'm not seeding it right, though I can't see why - I get a different value for seed every time. What gives?
>
>
>        unsigned seed = (unsigned)([NSDate timeIntervalSinceReferenceDate] * 10000.0);
>
>        NSLog(@"launched, seed = %ld", seed );
>        srandom( seed );

I'm not sure what your problem is, but I believe arc4random() has
superseded random() for a while now.
_______________________________________________

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: Seeding random() randomly
      • From: Jeffrey Walton <email@hidden>
    • Re: Seeding random() randomly
      • From: Graham Cox <email@hidden>
    • Re: Seeding random() randomly
      • From: David Duncan <email@hidden>
References: 
 >Seeding random() randomly (From: Graham Cox <email@hidden>)

  • Prev by Date: Seeding random() randomly
  • Next by Date: Re: Seeding random() randomly
  • Previous by thread: Seeding random() randomly
  • Next by thread: Re: Seeding random() randomly
  • Index(es):
    • Date
    • Thread