Re: anyObject
Re: anyObject
- Subject: Re: anyObject
- From: Marco Scheurer <email@hidden>
- Date: Thu, 31 Jan 2002 18:00:08 +0100
On Thursday, January 31, 2002, at 05:30 pm, Robert Goldsmith wrote:
I have searched the archives but there seems no mention of this
problem - sorry if it has been discussed before.
I am trying to use the NSSet method anyObject which, according to the
docs, returns a random object selected from the set or, if the set is
empty, nil.
However, the following lines of code don't seem to do that:
[...]
2002-01-31 16:09:16.979 Mind[7601] <NSCFSet: 0x6bd30> (0, 1, 2, 3, 4,
5, 6, 7, 8, 9)
Size of the set is 10
(which shows the values have been stored ok) followed by 100 selections
of the the NSNumber object that holds the value 0.
There is random and random... In that case, the method name, anyObject,
is more explicit than the doc. It just returns an object, and the first
one found is as good as any other. There is nothing random in this
process.
You'll have to use a random number generator do to this kind of things.
Marco Scheurer
Sen:te, Lausanne, Switzerland
http://www.sente.ch