In Actionscipt, Parent means the object which contains the instance. So if a car has a wheel, wheel can tell the car to move forward with
parent.moveForward
However, in Obj-C, parent refers to the super class (not sure why they have super and parent mean the same thing).
I can’t find any equivalent to the Action-script style parent, but then I don’t really know what to even look for. Is there an easy way to do this in Obj-C, or do I have to manually pass a reference to the instance when I create it? I’ve tried this and It’s throwing an error, but since I’m new to Obj-C, I just wanted to make sure I’m taking the right course of action.
To follow on to the composition answer – the usual pattern would be to have the parent either create or be given the objects it’s holding onto, and then set itself as some kind of delegate for each one (if they need to reference the parent) – note that delegate references unlike most other things are almost never retained, usually assigned.
so in your example, the parent would tell each wheel:
then the wheel could tell the parent:
Though frankly the metaphor in the example is losing me a bit there!
Another approach is to update variables in the contained obejcts that the parent would poll somehow (this approach for example can work well making views that get pushed using the navigation controller, and then return where the master view has to do something based on changes made in the sub views).