NSMutableArray help
Hello everyone I a bit new to iOS programming so here goes.
I have a class called sceneObjects and from that I have a few subclasses "Ants" and "Food". All of these are stored in a NSMutableArray of sceneObjects. The problem is that Ants need to know the location of Food so how do I access the right elements and give them other elements information within the same array.
Thank you for your time.
I have a class called sceneObjects and from that I have a few subclasses "Ants" and "Food". All of these are stored in a NSMutableArray of sceneObjects. The problem is that Ants need to know the location of Food so how do I access the right elements and give them other elements information within the same array.
Thank you for your time.
create 2 more arrays called antObjects and foodObjects and stick ants and foods into each respectively.
The cost storage of doing so is negligible, and now you can easily iterate through them.
The slow way would be to iterate over each sceneObject and test the type (or have the class store some "type" you can query on)
The cost storage of doing so is negligible, and now you can easily iterate through them.
The slow way would be to iterate over each sceneObject and test the type (or have the class store some "type" you can query on)
*ahem* SceneObject, not sceneObject, please. Stick to Obj-C conventions when using Obj-C. 
Other than that, ditto to skyhawk.

Other than that, ditto to skyhawk.
Thanks skyhawk that sounds like just what I need to do.

