I get memory leak warning when I addsubView to Current ViewController….This is my code..
NoOfGolferViewController *objNoOfGolferViewController = [[NoOfGolferViewController alloc]initWithNibName:@"NoOfGolferViewController" bundle:nil];
[objNoOfGolferViewController setParent:self];
[objNoOfGolferViewController.view setFrame:CGRectMake(15, 110, 290, 330)];
[self.view addSubview:objNoOfGolferViewController.view];
and when I release object
[objNoOfGolferViewController release];
Application get crashed by giving EXE_BAD_ACCESS message.
How can I solve this memory leak warning?
Thanks in advance..
You need to keep your
objNoOfGolferViewControllerobject alive as long as its view is visible or used in current controller. The best solution it seems is to make it an instance variable of your current class and releaseobjNoOfGolferViewControllerin its dealloc method