tags:

views:

36

answers:

1

Hi,

I have a main class and three other classes, now i need to give the reference of the other three objects that is created in their own classes to the main class object.How to do it ?

A: 

Set up attributes in the main class to hold pointers to the other classes and then use an init method to set them at the start or setters

e.g. for classes A and B

class Main : NSObject
{
  A* anAObject;
  B* aBObject;
}

// implementation of init -needs to have memory management I've done the simplest
initWithA:(A* anA) andB:(B* aB)
{
   anObject = [anA retain];
   aBObject = [aB retain];
}
Mark