I wonder, from a memory point of view, if what I'm doing is correct.
First, the files that I want to re-use are subclasses of UIViews
.
In my UIViewcontroller
, I declare an object like this :
World_1_ViewController.h :
#import "Level1.h"
@class Level1;
@interface World_1_ViewController : UIViewController <UIAccelerometerDelegate>
{
Some things....
Level1 * level1view;
}
World_1_ViewController.m :
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
level1view = [[Level1 alloc] init];
[self.view addSubview:level1view];
//Other things...
}
You could see that it's init a first time when the UIViewController
World_1_ViewController
is opening, in the viewDidLoad
method.
Now i need to re-use this object, level1view
, so in one of my methods which come after, I use:
[level1view release];
level1view = [[Level1 alloc] init];
[self.view addSubview:level1view];
//Some methods...
Is it correct from a memory point of view? Or what should I do ?