Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Select a random object in a Cocoa collection?

Select a random object in a Cocoa collection?
Thread Tools
Mac Enthusiast
Join Date: Sep 2001
Location: McKinney, TX
Status: Offline
Reply With Quote
Sep 27, 2001, 10:59 AM
 
I am developing an application where I want to randomly select an object from a collection. My initial instinct was to use an NSMutableArray and use random() to generate an index. As I was looking through the Cocoa frameworks, I came across the NSSet class and its anyObject method that would appear, at first glance, to do what I want.

I'd like to keep with the Cocoa frameworks whereever possible, so my question is this: How random is NSSet's anyObject method, i.e. would I get much better randomness using random() and an NSMutableArray?

TIA.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:15 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2