views:

38

answers:

1

i am doing the following to initialize the viewcontroller(piechartController) to the viewcontroller's(covVC) variable like following …is it right to change the view controller variable ?

  self.pie = [[ChatController alloc] initWithNibName:@"Chat" bundle:nil];
self.covVC = [[coverAssetController alloc] init];
self.covVC.pieObj = self.pie;

coverAssetController.h------>

 @interface coverAssetController : UIViewController {


    ChatController *pieObj;
 }
+1  A: 

You need to add a property in your coverAssetController :

 @interface coverAssetController : UIViewController {

    PieChartController *pieObj;

 }
@property(nonatomic, assign) PieChartController *pieObj;

And in you implementation add :

@synthesize pieObj;

Anyway, it's ok to do it ^^ But in fact it depends what you want to do etc etc.

Vinzius
To add to this: I would recommend declaring the pieObj property with "(nonatomic, retain)" so it's automatically retained when set. Note that this means you'd need to do [pie release] after assigning it to self.covVC.pieObj. In general, though not always, it's good to retain an object if you want to be sure it won't get deallocated by someone else while another class still needs it.
Steve N
Yeah, it depends of the person. Me I prefer to assign and doing the retain myself ^^
Vinzius