XCode / iOS: Iterating through all instances of a given class?

I am working on a 3d game engine for the iPhone and Im currently working out how Im going to be handling all of my 3D objects. I have a class that holds information pertaining to each 3D object such as vertexdata, texture information, etc.

I also have a method that is called once every x milleseconds that handles rendering the 3d scene.

  • How to invoke iPhone Maps for Directions with Current Location as Start Address
  • Keypath <transientproperty> not found in entity
  • Xcode and XIB self documentation
  • Explanation of NSIncrementalStore in plain english
  • Detect first launch of iOS app
  • How to draw wavy line on iOS device
  • Inside of this method, I would like to loop through all of my 3D objects to get access to their render data.

    I realize I could store pointers to all of my 3D objects in an array and iterate through this array, but before venturing down this possibly unnecessary road I was wondering if there was away to simply iterate through all instances of a given class (ie my 3d object class), as this would solve my problem.


    For (obj in AEobject3D){

    render obj


    Is something like this possible? If so please excuse the ignorance, I cant seem to find information in the docs / internet, and Im still learning my way through Objective C.

    – Adam Eisfeld

    2 Solutions Collect From Internet About “XCode / iOS: Iterating through all instances of a given class?”

    No, there’s no built-in way to do this. If you wanted to implement it yourself, you’d still have to use an array to keep track of the objects. So I suggest you just use an array in the first place.

    Just make an array and be some with it. For instance, UIKit uses the concept of subviews too, which are arrays in arrays.