Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chaonic

macrumors newbie
Original poster
Feb 22, 2008
12
0
Hey guys...

If I have a bunch of objects named "sq1", "sq2", "sq3", etc. Is there an easy way to reference each from within a for loop?

For instance, in ActionScript I could do...

Code:
this["sq"+i]

...or something like that. Is there an Objective-C equivalent?
 

Encryptic

macrumors member
Jul 27, 2008
46
0
Instead of creating hard-coded variables with names which you wish to access sequentially, create an array. Then you just access them with an index.

Alternative two, you could create a dictionary of the variables and reference them by string, but that doesn't seem like the best option.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.