Weird.

Setting a breakpoint on srandom, setstate or srandomdev never triggers except 
for my own call of it. Using srandomdev doesn't change anything.

Switching to arc4random() gives me a varying random sequence, so that's a 
usable solution to my problem. But the behaviour with random() I'm seeing is 
mysterious.

--Graham




On 27/05/2011, at 11:15 AM, Dave Keck wrote:

>> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to